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

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

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

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

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

23
I N -C LASS E XERCISE Prob. 11.3 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: 50-100 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.

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. 0110 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.

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

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