Download presentation
Presentation is loading. Please wait.
1
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 12: Mass-Storage Systems
2
12.2 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Operating System and Disk Mgmt Major OS jobs are to manage physical devices and to present a virtual machine abstraction to applications For hard disks, the OS provides two abstractions: Raw device – an array of data blocks. File system – the OS queues and schedules the interleaved requests from several applications.
3
12.3 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 12: Mass-Storage Systems Data Transfer from Memory to/from Disk Disk Structure Disk Attachment Disk Scheduling Disk Management Swap-Space Management RAID Structure Disk Attachment - skip Stable-Storage Implementation - skip Tertiary Storage Devices- skip Operating System Issues - skip Performance Issues - skip
4
12.4 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 4 Data Transfer from Memory to Disk Reading and Writing Files- n Logical record - the unit of data as user thinks of it n Physical record - the unit of data that OS processes n Block - basic unit of data transfer to disk (same size as physical record) n Buffer - storage area in main memory for use in data transfer (same size as physical record)
5
12.5 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 5 Writing Data Out to Disk write (fd, data_addr, count); /* fd = file descriptor */ for (i=0; i<=m; i++) /* write big array to disk */ for (j=0; j<=n; j++) write(fd, a[i,j], sizeof a[0,0]);
6
12.6 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 6 Buffering n OS must fill up one buffer before actually writing the block out to disk.
7
12.7 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 7 Buffering Schemes
8
12.8 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 8 Buffering Schemes (cont’d)
9
12.9 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 9 Write System Call Pseudo-code for write system call: write(fd, data_addr, count) { if (enough space remains in current buffer) { copy count bytes from data_addr to buffer bufcnt =+ count; } else { b = number of bytes still available in the buffer: copy b bytes of data into buffer; /* buffer is now full */ write buffer to disk; reset buffer pointer to beginning of buffer; reset bufcnt to zero; copy (count - b) bytes to buffer; bufcnt =+ (count-b); }
10
12.10 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 10 OS Buffer Pool
11
12.11 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Overview of Disks Magnetic disks provide bulk of secondary storage of modern computers Drives rotate at 60 to 200 times per second Transfer rate is rate at which data flow between drive and computer Positioning time (random-access time) is time to move disk arm to desired cylinder (seek time) and time for desired sector to rotate under the disk head (rotational latency) Head crash results from disk head making contact with the disk surface Drive attached to computer via I/O bus Busses vary, including EIDE, ATA, SATA, USB, Fibre Channel, SCSI Host controller in computer uses bus to talk to disk controller built into drive or storage array
12
12.12 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Moving-head Disk Mechanism
13
12.13 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Disk Structure Disk drives are addressed as large 1-dimensional arrays of logical blocks, where the logical block is the smallest unit of transfer. The 1-dimensional array of logical blocks is mapped into the sectors of the disk sequentially. Sector 0 is the first sector of the first track on the outermost cylinder. Mapping proceeds in order through that track, then the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost.
14
12.14 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Disk Attachment Host-attached storage accessed through I/O ports talking to I/O busses SCSI itself is a bus, up to 16 devices on one cable, SCSI initiator requests operation and SCSI targets perform tasks Each target can have up to 8 logical units (disks attached to device controller FC is high-speed serial architecture the basis of storage area networks (SANs) in which many hosts attach to many storage units Can be arbitrated loop (FC-AL) of 126 devices
15
12.15 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Network-Attached Storage Network-attached storage (NAS) is storage made available over a network rather than over a local connection (such as a bus) NFS and CIFS are common protocols Implemented via remote procedure calls (RPCs) between host and storage New iSCSI protocol uses IP network to carry the SCSI protocol
16
12.16 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Storage Area Network Common in large storage environments (and becoming more common) Multiple hosts attached to multiple storage arrays - flexible
17
12.17 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Disk Scheduling The operating system is responsible for using hardware efficiently — for the disk drives, this means having a fast access time and disk bandwidth. Disk bandwidth is the total number of bytes transferred, divided by the total time between the first request for service and the completion of the last transfer. Access time has two major components Seek time is the time for the disk are to move the heads to the cylinder containing the desired sector. Rotational latency is the additional time waiting for the disk to rotate the desired sector to the disk head. Algorithms to minimize seek time: FCFS, SSTF, SCAN, C-SCAN, C-LOOK
18
12.18 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Disk Scheduling Algorithms Schedule the servicing of disk I/O requests wrt seek time. We illustrate them with a request queue of cylinder numbers (0-199). 98, 183, 37, 122, 14, 124, 65, 67 Head pointer 53
19
12.19 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition FCFS Illustration shows total head movement of 640 cylinders.
20
12.20 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition SSTF Selects the request with the minimum seek time from the current head position. SSTF scheduling is a form of SJF scheduling; may cause starvation of some requests. Illustration shows total head movement of 236 cylinders.
21
12.21 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition SSTF (Cont.)
22
12.22 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition SCAN The disk arm starts at one end of the disk, and moves toward the other end, servicing requests until it gets to the other end of the disk, where the head movement is reversed and servicing continues. Sometimes called the elevator algorithm. Illustration shows total head movement of 208 cylinders.
23
12.23 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition SCAN (Cont.)
24
12.24 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition C-SCAN Provides a more uniform wait time than SCAN. The head moves from one end of the disk to the other. servicing requests as it goes. When it reaches the other end, however, it immediately returns to the beginning of the disk, without servicing any requests on the return trip. Treats the cylinders as a circular list that wraps around from the last cylinder to the first one.
25
12.25 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition C-SCAN (Cont.)
26
12.26 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition C-LOOK Version of C-SCAN Arm only goes as far as the last request in each direction, then reverses direction immediately, without first going all the way to the end of the disk.
27
12.27 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition C-LOOK (Cont.)
28
12.28 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Selecting a Disk-Scheduling Algorithm SSTF is common and has a natural appeal SCAN and C-SCAN perform better for systems that place a heavy load on the disk. Performance depends on the number and types of requests. Requests for disk service can be influenced by the file-allocation method. The disk-scheduling algorithm should be written as a separate module of the operating system, allowing it to be replaced with a different algorithm if necessary. Either SSTF or C-LOOK is a reasonable choice for the default algorithm.
29
12.29 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Disk Management Low-level formatting, or physical formatting — Dividing a disk into sectors that the disk controller can read and write. To use a disk to hold files, the operating system still needs to record its own data structures on the disk. Partition the disk into one or more groups of cylinders. Logical formatting or “making a file system”. Boot block initializes system. The bootstrap is stored in ROM. Bootstrap loader program. Methods such as sector sparing used to handle bad blocks.
30
12.30 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Swap-Space Management Swap-space — Virtual memory uses disk space as an extension of main memory. Swap-space can be carved out of the normal file system,or, more commonly, it can be in a separate disk partition. Swap-space management 4.3BSD allocates swap space when process starts; holds text segment (the program) and data segment. Kernel uses swap maps to track swap-space use. Solaris 2 allocates swap space only when a page is forced out of physical memory, not when the virtual memory page is first created.
31
12.31 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID Structure RAID – multiple disk drives provides reliability via redundancy. RAID is arranged into six different levels. Randy Katz, UC Berkeley
32
12.32 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID (cont) Several improvements in disk-use techniques involve the use of multiple disks working cooperatively. Disk striping uses a group of disks as one storage unit. RAID schemes improve performance and improve the reliability of the storage system by storing redundant data. Mirroring or shadowing keeps duplicate of each disk. Block interleaved parity uses much less redundancy.
33
12.33 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID Levels
34
12.34 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Data is Striped for improved performance Distributes data over multiple disks to make them appear as a single fast large disk Allows multiple I/Os to be serviced in parallel Multiple independent requests serviced in parallel A block request may be serviced in parallel by multiple disks Data is Redundant for improved reliability Large number of disks in an array lowers the reliability of the array Reliability of N disks = Reliability of 1 disk /N Example: – 50,000 hours / 70 disks = 700 hours – Disk System MTTF drops from 6 years to 1 month Arrays without redundancy are unreliable RAID
35
12.35 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID 0 (Non-redundant) Stripes Data; but does not employ redundancy Lowest cost of any RAID Best Write performance – can be done in parallel to multiple disks Any single disk failure is catastrophic Used in environments where performance is more important than reliability. RAID
36
12.36 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition D0D3D2D1 D4 D7 D6D5 D8 D11 D10 D9 D12 D15 D14D13 D19 D18D17D16 Stripe RAID Disk 1Disk 4Disk 3Disk 2
37
12.37 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID 1 (Mirrored) Uses twice as many disks as non-redundant arrays - 100% Capacity Overhead - Two copies of data are maintained Data is simultaneously written to both arrays Data is read from the array with shorter queuing, seek and rotation delays - Best Read Performance. When a disk fails, mirrored copy is still available Used in environments where availability and performance (I/O rate) are more important than storage efficiency. RAID
38
12.38 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID (0 + 1) and (1 + 0)
39
12.39 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID 2 (Memory Style ECC) Uses Hamming code - parity for distinct overlapping subsets of data # of redundant disks is proportional to log of total # of disks - Better for large # of disks - e.g., 4 data disks require 3 redundant disks If disk fails, other data in subset is used to regenerate lost data Multiple redundant disks are needed to identify faulty disk RAID
40
12.40 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID 3 (Bit Interleaved Parity) Data in a block is stored bit -wise over the data disks Uses Single parity disk to tolerate disk failures - Overhead is 1/N Logically a single high capacity, high transfer rate disk Reads access data disks only; Writes access both data and parity disks Used in environments that require high BW (Scientific, Image Processing, etc.), and not high I/O rates 100100100100 111010111010 110111110111 100101100101 110011110011 RAID
41
12.41 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID 4 (Block Interleaved Parity) Similar to bit-interleaved parity disk array; except data is block- interleaved (Striping Units) Read requests smaller than one striping unit, access one Striping unit Write requests update the data block; and the parity block. Generating parity requires 4 I/O accesses (RMW) Parity disk gets updates on all writes - a bottleneck RAID
42
12.42 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID 5 (Block-Interleaved Distributed Parity) Eliminates the parity disk bottleneck in RAID 4 - Distributes parity among all the disks Data is distributed among all disks All disks participates in read requests - Better performance than RAID 4 Write requests update the data block; and the parity block. Generating parity requires 4 I/O accesses (RMW) Left symmetry v.s. Right Symmetry - Allows each disk to be traversed once before any disk twice RAID
43
12.43 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition D0PD3D2D1 D4D7PD6D5 D8D11D10PD9 D12D15D14D13P PD19D18D17D16 Stripe Unit Stripe RAID
44
12.44 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition D0’D0PD3D2D1 + + Old Parity (2. Read) Old Data 1. Read New Data D0’P’D3D2D1 3. Write New Data 4. Write New Parity RAID
45
12.45 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID 6 (P + Q Redundancy) Uses Reed-Solomon codes to protect against up to 2 disk failures Data is distributed among all disks Two sets of parity P & Q Write requests update the data block; and the parity blocks. Generating parity requires 6 I/O accesses (RMW) - update both P & Q Used in environments that require stringent reliability requirements RAID
46
12.46 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Comparisons Read/Write Performance RAID 0 provides the best Write performance RAID 1 provides the best Read Performance Cost - Total # of Disks RAID 1 is most expensive - 100% capacity overhead - 2N Disks RAID 0 is least expensive - N Disks - no redundancy RAID 2 needs N + ceiling(log 2 N) + 1 RAID 3, RAID 4 & RAID 5 needs N + 1 disks RAID Comparisons
47
12.47 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Preferred Environments RAID 0: Performance & capacity are more important than reliability RAID 1: High I/O rate, high availability environments RAID 2: Large I/O Data Transfer RAID 3: High BW Applications (Scientific, Image Processing…) RAID 4: High bit BW Applications RAID 5 & RAID 6: Mixed Applications RAID
48
12.48 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition RAID LevelSmall ReadsSmall WritesLarge Reads Large WritesStorage Efficiency RAID 011111 RAID 111/21 RAID 31/G (G-1)/G RAID 51max(1/G,1/4)1(G-1)/G RAID 61max(1/G,1/6)1(G-2)/G The table below, which shows Throughput per $$ relative to RAID 0, assumes that G drives in an error correcting group RAID
49
12.49 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition What RAID for which application Fast Workstation: Caching is important to improve I/O rate If large files are installed, then RAID 0 may be necessary It is preferred to put the OS and swap files in separate drives from user drives to minimize movement between swap file area & user area. Small Server: RAID 1 is preferred Mid-Size Server: If more capacity is needed, then RAID 5 is recommended Large Server: e.g. Database Servers RAID 5 is preferred Separate different I/Os in mechanically independent arrays; place index & data files in databases in different arrays RAID
50
12.50 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Price per Megabyte of DRAM, From 1981 to 2004
51
12.51 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Price per Megabyte of Magnetic Hard Disk, From 1981 to 2004
52
12.52 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Price per Megabyte of a Tape Drive, From 1984-2000
53
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, End of Chapter 12
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.