1 / 33

Input/Output Management and Disk Scheduling

Input/Output Management and Disk Scheduling. Chapter 11 . Categories of I/O devices. Human-readable: printers video display keyboard... Machine Readable: disk, tape sensors... Communication line drivers modems. Main Characteristics. Data rate (bits or bytes?)

raleigh
Download Presentation

Input/Output Management and Disk Scheduling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Input/Output Management and Disk Scheduling Chapter 11 Chapter 11

  2. Categories of I/O devices • Human-readable: • printers • video display • keyboard... • Machine Readable: • disk, tape • sensors... • Communication • line drivers • modems... Chapter 11

  3. Main Characteristics • Data rate (bits or bytes?) • Unit of transfer (bit, byte, or block) • Data format • Error conditions • Interrupt signaling Chapter 11

  4. Varying data rates.... Chapter 11

  5. Stages of Evolution • No interrupts • Simple programmed I/O by CPU • Add simple controller to this: channel; • busy waiting or polling needed • CPU keeps asking channel whether it has finished • With interrupts • Add interrupts to this • simultaneous operation CPU & I/O • traffic I/O  Memory still goes through CPU • Introduce DMA: a controller to minimize CPU involvement. • CPU interrupted only after entire block has been transferred • DMA has complex instruction set (e.g. “if”) • DMA is complete separate CPU Chapter 11

  6. Direct Memory Access • Takes control of the system from the CPU to transfer data to and from memory over the system bus • Cycle stealing is used to transfer data on the system bus • CPU slowed down, but not as much as it would be without DMA • The CPU pauses one bus cycle to allow DMA to do its work • No interrupts occur until all data block transferred Chapter 11

  7. Possible DMA configuration 1 (communication unit/DMA involves bus: inefficient) Chapter 11

  8. Possible DMA configuration 2(communication betw. DMA and unit does not involve bus) Chapter 11

  9. Possible DMA configuration 3(very flexible, facilitates the inclusion of additional I/O units) Chapter 11

  10. OS Design Issues • Efficiency • I/O is usually the bottleneck! Extremely slow with respect to CPU • Generality: • Try to handle devices as much as possible in same manner • Use general-purpose primitives, hide peculiarities of devices from high-level modules • every file can be treated in terms of read. write, open, close, lock, unlock... Chapter 11

  11. Layering Models Lower levels hide details from higher ones Chapter 11

  12. I/O Buffering • Could buffer be in memory area of user process? • Probably not. Process in execution is subject to paging, suspension, etc. • so I/O must occur in a separate memory area (next solution) Chapter 11

  13. I/O Buffering • Block-Oriented • Information is stored in fixed sized blocks • Transfers are made a block at the time • Used for disks and tapes • Stream-oriented • Information unit is of variable size: a stream of bytes • special info, such as carriage return, will delimit its logical parts • Used for terminals, printers, communication ports, mouse and most other devices that are not secondary storage Chapter 11

  14. Single Buffer • Block-oriented • Input transfers made to buffer • As soon as user takes data, new input can start (similarly for output) • Read ahead, output and go (no wait) Chapter 11

  15. Shadow Double buffering • More independence between I/O and processing: a process can use the content of one buffer while the I/O device works with the other buffer • Normally invisible to programmer. Chapter 11

  16. Circular buffer • Generalized scheme, such as in the producer-consumer problem • Sometimes the I/O device can be faster, other times the user process can be faster • Peak demands are smoothed out Chapter 11

  17. Disk scheduling • Cylinder: the set of tracks that are in the same position with respect to read/write head (but book only considers tracks, not cylinders) Chapter 11 Silberschatz

  18. Disk performance parameters • To read or write, the disk head must be positioned at the desired track and at the beginning of the desired sector • Access time is the sum of: • Seek time • time it takes to position the head at the desired track (or cylinder) • Rotational delay or rotational latency • time its takes for the beginning of the sector to reach the head • Transfer time • Seek time >> Rotational Delay >> Transfer time Chapter 11

  19. Chapter 11

  20. Tracks and cylinders Chapter 11

  21. Chapter 11

  22. Timing of a Disk I/O Transfer Chapter 11

  23. Disk Scheduling Policies • Seek time is the reason for differences in performance • Seek time >> Rotational latency • For a single disk there will be a number of I/O requests • If requests are selected randomly, we will not get a good performance • we will assume that the requests for disk access of a number of user will be random • (but for a single user `locality of reference’ will again hold) • So it is important to devise better methods: • I/O system sorts the requests in some way Chapter 11

  24. Evaluating the policies • To evaluate the policies, we will use a random sequence of track accesses (see book): • Starting at track 100 and then • 55 58 39 18 90 160 150 38 184 • and calculate how many track traversal each policy will require to finish the sequence Chapter 11

  25. 55 58 39 18 90 160 150 38 184 FIFO policy: process requests in the order they arrive • From 100 to 55: 45 tracks traversed • From 55 to 58: 3 tracks traversed • From 58 to 39: 19 tracks traversed etc etc.... • In total: 45+3+19... = 498 tracks • 498 / 9 = 55.3 tracks traversed for the avg request Chapter 11

  26. The Shortest Service Time First policy (SSTF) • This policy looks each time at the queue of the waiting requests and chooses the one that can be served with the shortest seek from the current position. • From 100 to 90: 10 tracks • From 90 to 58: 32 • From 58 to 55: 3 • In total: 10+32+3... = 248 / 9 = 27.5 better! 55 58 39 18 90 160 150 38 184 90 58 55 39 38 18 150 160 184 Chapter 11

  27. The SCAN (or elevator) policy • Problem with the previous policy: it is possible that some requests will starve, because closer requests keep arriving!! • Solution: keep going in one direction until all requests are satisfied. Then change direction, and so on • 100  150 = 50; 150  160 = 10; 160  184 = 24; 184  90 = 94.... • 50+10+24+94+.... = 250 / 9 = 27.8 a bit worse than SSTF but no starvation 55 58 39 18 90 160 150 38 184 150 160 184 90 58 55 39 38 18 Chapter 11

  28. C-SCAN (Circular SCAN) • Similar behavior to SSTF • Problem with the previous policy: • nothing to do immediately after the arm reverses direction (already done) • waiting requests will be at the other end • C-SCAN: assumes that return trip to track is rapid (as it is in many drivers) • Disk is always scanned in one direction only • When the scan is complete, arm goes back to the beginning and restarts Chapter 11

  29. 18 return home 184 55 58 39 18 90 160 150 38 184 150 160 184 18 38 39 55 58 90 C-SCAN (Circular SCAN) • If the return home is considered as 184-18=166 then the average seek length is 35.8. • If it is considered 0, then 136 / 9 = 15 (only!) • In practice, it will be closer to 35 than to 15. Chapter 11

  30. Last in, First Out (LIFO) • Serve always the most recent request first! • Rationale: keep serving the same user may result in accessing nearby tracks • certainly true if file is sequential • applies the principle of locality to disk accesses • But may starve early users Chapter 11

  31. Chapter 11

  32. In practice... • For a realistic evaluation of disk times, one cannot assume simply that traversal of one track takes one unit of time • One must consider real arm motion times, which include a start time when the head picks up speed • One must also consider rotational delay and read times • Such times vary from disk unit to disk unit Chapter 11

  33. Important Concepts of Chapter 11 • Different types of I/O Devices • Different types of I/O Processing • Direct Memory Access • Buffering • Characteristics of disk units • Access time • Different disk scheduling algorithms • comparison Chapter 11

More Related