Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.

Similar presentations


Presentation on theme: "Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and."— Presentation transcript:

1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings

2 G IVEN C REDIT W HERE I T IS D UE Some of the lecture notes are borrowed from Dr. Mark Temte at Indiana University – Purdue University Fort Wayne and from Dr. Einar Vollset at Cornell University I have modified them and added new slides

3 I/O MANAGEMENT AND DISK SCHEDULING We have already discussed I/O techniques Programmed I/O Interrupt-driven I/O Direct memory access (DMA) Also mentioned logical I/O where the OS hides most of the details of device I/O in system service routines. Then processes see devices in general terms such as read, write, open, close, lock, unlock 3

4 O THER ISSUES... I/O buffering Physical disk organization Need for efficient disk access Disk scheduling policies RAID 4

5 I/O BUFFERING Can be block-oriented or stream-oriented Block-oriented buffering Information is stored in fixed-size blocks Transfers are made a block at a time Used for disks and tapes 5

6 I/O BUFFERING Stream-oriented Transfer information as a stream of bytes Used for terminals, printers, communication ports, mouse and other pointing devices, and most other devices that are not secondary storage 6

7 I/O BUFFERING I/O is a problem under paged virtual memory The target page of any I/O operation must be present in a page frame until the transfer is complete Otherwise, there can be single-process deadlock Example Suppose process P is blocked waiting for I/O event to complete Then suppose the target page for the I/O is swapped out to disk The I/O operation is subsequently blocked waiting for the target page to be swapped in, but the rules of suspension dictate that it stays suspended on the disk until the I/O event completes! 7

8 I/O BUFFERING Resulting OS complications The target page of any I/O operation must be locked in memory until the transfer is complete A process with pending I/O on any page may not be suspended Solution: Do I/O through a system I/O buffer in main memory assigned to the I/O request System buffer is locked in memory frame Input transfer is made to the buffer Block moved to user space when needed This decouples the I/O transfer from the address space of the application 8

9 9 Physical Disk Organization read-write head track sectors

10 10 Physical Disk Organization boom cylinder

11 P HYSICAL DISK ORGANIZATION When the disk drive is operating, the disk is rotating at constant speed To read or write, the disk head must be positioned on the desired track and at the beginning of the desired sector Once the head is in position, the read or write operation is then performed as the sector moves under the head Seek time is the time it takes to position the head on the desired track Rotational delay or rotational latency is the additional time it takes for the beginning of the sector to reach the head once the head is in position Transfer time is the time for the sector to pass under the head 11

12 P HYSICAL DISK ORGANIZATION Access time = seek time + rotational latency + transfer time Efficiency of a sequence of disk accesses strongly depends on the order of the requests Adjacent requests on the same track avoid additional seek and rotational latency times Loading a file as a unit is efficient when the file has been stored on consecutive sectors on the same track/cylinder of the disk 12

13 T RANSFER T IME Depend on the rotation speed of the disk: T = b/(rN) Where T: transfer time b: number of bytes to be transferred N: number of bytes on a track/cylinder r: rotation speed, in revolutions per second Thus, the total average access time is T s + 0.5/r + b/(rN), where T s is the average seek time.

14 A T IME C OMPARISON Consider a disk with an advertised average seek time of 4ms, rotation speed of 7500 rpm, and 512-byte sectors with 500 sectors per track. Suppose that we wish to read a file consisting of 2500 sectors for a total of 1.28 Mbytes. We would like to estimate the total time for the transfer. 1) Sequential organization: the file is stored on 5 adjacent tracks (5 tracks * 500 sectors/track = 2500 sectors). 2) The sectors are distributed randomly over the disk.

15 D ISK S CHEDULING P OLICIES Seek time is the reason for differences in performance For a single disk there will be a number of I/O requests If requests are selected randomly, get poor performance

16 D ISK S CHEDULING P OLICIES First-in, first-out (FIFO) Process request sequentially Fair to all processes Approaches random scheduling in performance if there are many processes Example: 55, 58, 39, 18, 90, 160, 150, 38, 184

17 D ISK S CHEDULING P OLICIES Shortest Service/Seek Time First Select the disk I/O request that requires the least movement of the disk arm from its current position Always choose the minimum seek time Example: 55, 58, 39, 18, 90, 160, 150, 38, 184 Requests for tracks far away from the current position may never be served, if requests for closer tracks are issued continuously

18 D ISK S CHEDULING P OLICIES SCAN (aka Elevator Algorithm) Arm moves in one direction only, satisfying all outstanding requests until it reaches the last track in that direction Direction is reversed Example: 55, 58, 39, 18, 90, 160, 150, 38, 184

19 D ISK S CHEDULING P OLICIES C-SCAN Restricts scanning to one direction only When the last track has been visited in one direction, the arm is returned to the opposite end of the disk and the scan begins again In case of repetitive requests to one track, we will see “arm stickiness” in SSTF, SCAN, C-SCAN

20 D ISK S CHEDULING P OLICIES N-step-SCAN Segment the disk request queue into subqueues of length N Subqueues are processed one at a time, using SCAN New requests added to other queue when a queue is processed

21 D ISK S CHEDULING P OLICIES FSCAN Two subqueues One queue is empty for new requests

22 Disk Scheduling Algorithms

23 I N -C LASS E XERCISE Prob a) Perform the same type of analysis as that of the previous table for the following sequence of disk track requests: 27, 129, 110, 186, 147, 41, 10, 64, 120. Assume that the disk head is initially positioned over track 100 and is moving in the direction of decreasing track number. b) Do the same analysis, but now assume that the disk head is moving in the direction of the increasing track number.

24 RAID M OTIVATION Disks are improving, but not as fast as CPUs 1970s seek time: ms. 2000s seek time: <5 ms. Factor of 20 improvement in 3 decades We can use multiple disks for improving performance By striping files across multiple disks (placing parts of each file on a different disk), parallel I/O can improve access time Striping reduces reliability What’s the mean time between failures of 100 disks, assuming T as the mean time between failures of one disk? The mean time between failures of 100 disks = 1/100 times of the mean time between failures of one disk So, we need striping for performance, but we need something to help with reliability To improve reliability, we can add redundant data to the disks, in addition to striping

25 RAID A RAID is a Redundant Array of Inexpensive Disks “I” is also for “Independent” The alternative is SLED, single large expensive disk Disks are small and cheap, so it’s easy to put lots of disks (10s to 100s) in one box for increased storage, performance, and availability The RAID box with a RAID controller looks just like a SLED to the computer Data plus some redundant information is striped across the disks in some way How that striping is done is key to performance and reliability.

26 R AID L EVEL 0 Level 0 is nonredundant disk array Files are striped across disks, no redundant info High read throughput Best write throughput (no redundant info to write) Any disk failure results in data loss Reliability worse than SLED Stripe 0 Stripe 4 Stripe 3Stripe 1Stripe 2 Stripe 8 Stripe 10 Stripe 11 Stripe 7 Stripe 6Stripe 5 Stripe 9 data disks

27 R AID L EVEL 1 Mirrored Disks Data is written to two places On failure, just use surviving disk On read, choose fastest to read Write performance is same as single drive, read performance is 2x better Replication redundancy is expensive data disksmirror copies Stripe 0 Stripe 4 Stripe 3Stripe 1Stripe 2 Stripe 8 Stripe 10 Stripe 11 Stripe 7 Stripe 6Stripe 5 Stripe 9 Stripe 0 Stripe 4 Stripe 3Stripe 1Stripe 2 Stripe 8 Stripe 10 Stripe 11 Stripe 7 Stripe 6Stripe 5 Stripe 9

28 P ARITY AND H AMMING C ODES What do you need to do in order to detect and correct a one-bit error ? Suppose you have a binary number, represented as a collection of bits:, e.g Detection is easy Parity: Count the number of bits that are on, see if it’s odd or even EVEN parity is 0 if the number of 1 bits is even Parity( ) = P0 = b0  b1  b2  b3 Parity( ) = 0 if all bits are intact Parity(0110) = 0, Parity(01100) = 0 Parity(11100) = 1 => ERROR! Parity can detect a single error, but can’t tell you which of the bits got flipped

29 H AMMING C ODE H ISTORY In the late 1940’s Richard Hamming recognized that the further evolution of computers required greater reliability, in particular the ability to not only detect errors, but correct them. His search for error-correcting codes led to the Hamming Codes, perfect 1-error correcting codes, and the extended Hamming Codes, 1-error correcting and 2-error detecting codes.

30 P ARITY AND H AMMING C ODES Detection and correction require more work Hamming codes can detect & correct single bit errors [7,4] binary Hamming Code h0 = b0  b1  b3 h1 = b0  b2  b3 h2 = b1  b2  b3 H0( ) = 0 H1( ) = 1 H2( ) = 0 Hamming( ) = = If a bit is flipped, e.g. a = h0  b0  b1  b3 = 1 b = h1  b0  b2  b3 = 0 c = h2  b1  b2  b3 = 1 abc =, the 5 th bit is in error and switch it

31 E XTENDED [8,4] BINARY H AMM. C ODE As with the [7,4] binary Hamming Code: h0 = b0  b1  b3 h1 = b0  b2  b3 h2 = b1  b2  b3 Add a new bit p such that p = b0  b1  b2  b3  h0  h1  h2. i.e., the new bit makes the XOR of all 8 bits zero. p is called a parity check bit. Assume at most 2 errors: If parity check passes and abc = 000, the system is correct; If parity check passes and abc ≠ 000, the system has two errors; If parity check fails, there is one error and abc indicates which bit is in error.

32 R AID L EVEL 2 Bit-level striping with Hamming (ECC) codes for error correction All 7 disk arms are synchronized and move in unison Complicated controller Single access at a time Tolerates only one error data disks Bit 0Bit 3Bit 1Bit 2Bit 4Bit 5Bit 6 ECC disks

33 R AID L EVEL 3 Use a parity disk Each bit on the parity disk is a parity function of the corresponding bits on all the other disks A read accesses all the data disks A write accesses all data disks plus the parity disk On a disk failure, read remaining disks plus parity disk to compute the missing data data disks Parity disk Bit 0Bit 3Bit 1Bit 2Parity

34 RAID 3 X4(i) = X3(i)  X2(i)  X1(i)  X0(i) If drive X1 has failed. How to recover it?

35 R AID L EVEL 4 Combines Level 0 and 3 – block-level parity with Stripes A read accesses all the data disks A write accesses all data disks plus the parity disk data disks Parity disk Stripe 0Stripe 3Stripe 1Stripe 2P0-3 Stripe 4 Stripe 8 Stripe 10 Stripe 11 Stripe 7 Stripe 6Stripe 5 Stripe 9 P4-7 P8-11

36 RAID 4 ( BLOCK - LEVEL PARITY ) X4(i) = X3(i)  X2(i)  X1(i)  X0(i) How to execute a write operation, for instance on drive X1? Heavy load on the parity disk

37 RAID 5 (block-level distributed parity)

38 RAID 6 (dual redundancy) Level 5 with an extra parity bit, which is generated with a different and independent data check algorithm Can tolerate two failures

39

40 I/O BUFFERING FOR THROUGHPUT Perform input transfers in advance of requests being made With I/O buffers, an application can process the data from one I/O request while awaiting another Time needed to process a block of data... without buffering = C + T with buffering = M + max{ C, T } where: C = computation time T = I/O memory/disk transfer time M = memory/memory transfer time (buffer to user) Perform output transfers sometime after the request is made 40

41 D OUBLE BUFFERING Use two system buffers instead of one A process can transfer data to or from one buffer while the operating system empties or fills the other buffer 41

42 C IRCULAR BUFFERING More than two buffers are used List of system buffers are arranged in a circle Appropriate in applications where there are bursts of I/O requests 42

43 S OME R AID I SSUES Granularity fine-grained: Stripe each file over all disks. This gives high throughput for the file, but limits to transfer of 1 file at a time coarse-grained: stripe each file over only a few disks. This limits throughput for 1 file but allows more parallel file access Redundancy concentrate redundancy info on a small number of disks: partition the set into data disks and redundant disks uniformly distribute redundancy info on disks: avoids load- balancing problems


Download ppt "Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and."

Similar presentations


Ads by Google