Download presentation
Presentation is loading. Please wait.
1
Day 30 I/O Management and Disk Scheduling
2
I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer –Data representation –Error conditions
3
Categories of devices that engage in I/O Human readable e.g. printer, mouse Human readable e.g. printer, mouse Machine readable e.g. tape, disk Machine readable e.g. tape, disk Communication devices e.g. modem Communication devices e.g. modem
4
Organization of the I/O function Programmed I/O Programmed I/O –Program busy-waits while waiting for I/O device to respond. Interrupt-driven I/O Interrupt-driven I/O –I/O devices have the capacity to interrupt the processor and therefore allow the processor to run other processes while waiting for I/O device to respond.
5
Organization of the I/O function Direct Memory Access Direct Memory Access –Uses interrupts to communicate with the processor. –Assists with transfer of large amounts of data.
6
DMA Processor sends a DMA request. Processor sends a DMA request. –Read or write data from I/O device. –Which I/O device –Starting address in memory. –Number of words to transfer Processor gets an ACK from DMA controller. Processor gets an ACK from DMA controller. Processor does other work. Processor does other work. DMA transfers the data. DMA transfers the data. –It occasionally cycle steals i.e. causes the processor memory cycle to stall while it uses the memory bus to transfer data. When done, the controller interrupts the processor. When done, the controller interrupts the processor.
7
Operating system requirements to handle I/O devices Efficiency Efficiency –I/O devices are slow. –Use multi-programming. –Suspend processes. Generality Generality –Handle all devices in a uniform manner. –Use an hierarchical model. The layers further down the hierarchy (away from the OS) are more device specific. The layers further down the hierarchy (away from the OS) are more device specific.
8
Disk scheduling To read or write, the disk head must be positioned at the desired track and at the beginning of the desired sector To read or write, the disk head must be positioned at the desired track and at the beginning of the desired sector Seek time Seek time –time it takes to position the head at the desired track Initial startup time Initial startup time Time to traverse tracks Time to traverse tracks Rotational delay or rotational latency Rotational delay or rotational latency –time its takes for the beginning of the sector to reach the head
12
http://computer.howstuffworks.com/hard-disk5.htm
13
Disk scheduling The order in which the disk requests are made affects the time it takes to traverse the sectors and hence the seek time. The order in which the disk requests are made affects the time it takes to traverse the sectors and hence the seek time. Disk scheduling aims at reducing the traversal time. Disk scheduling aims at reducing the traversal time.
14
Number of tracks = 200 Current position of head is track 100 Request sequence: 55,58,39,18,90,160,150,38,184 FIFO
15
Priority Decision made outside of the disk management software. Decision made outside of the disk management software. Give priority to shorter jobs, interactive jobs. Give priority to shorter jobs, interactive jobs.
16
Last In First Out Satisfy the most recent request. Satisfy the most recent request. In systems that do sequential processing, will require less arm movement. In systems that do sequential processing, will require less arm movement. Could result in starvation. Could result in starvation.
17
Shortest Service Time First Least movement of the disk arm from its current position Least movement of the disk arm from its current position Starvation possible Starvation possible
18
Number of tracks = 200 Current position of head is track 100 Request sequence: 55,58,39,18,90,160,150,38,184
19
SCAN (Elevator) Eliminate starvation Eliminate starvation Move the arm in one direction, until there are no more tracks or no more requests in that direction (LOOK) Move the arm in one direction, until there are no more tracks or no more requests in that direction (LOOK) Reverse direction and repeat Reverse direction and repeat Does not exploit locality. Does not exploit locality. –Biased against the most recently used tracks. Favors the innermost and outermost tracks. Favors the innermost and outermost tracks.
20
Number of tracks = 200 Current position of head is track 100 Request sequence: 55,58,39,18,90,160,150,38,184
21
C-SCAN (Circular) Service requests only in one direction. (Use LOOK to stop) Service requests only in one direction. (Use LOOK to stop) Reduces the maximum delay experienced by new requests. Reduces the maximum delay experienced by new requests.
23
N-step-SCAN Arm-stickiness occurs with SCAN and C- SCAN Arm-stickiness occurs with SCAN and C- SCAN Split the queue into smaller queues of length N Split the queue into smaller queues of length N While servicing a sub-queue, new requests are added to another sub-queue. While servicing a sub-queue, new requests are added to another sub-queue. Must completely service a sub-queue before moving to another sub-queue. Must completely service a sub-queue before moving to another sub-queue.
24
Example Requests Requests –2,98,55,34,45,23,24,25,26,27,…. (Scheduled with SCAN) (Scheduled with SCAN) –2, 23, 24, 25, 26, 27,……, 34, 45, 55, 98 N = 4 (Scheduled with N-step-SCAN) N = 4 (Scheduled with N-step-SCAN) –2, 98, 55, 34 (2, 34, 55, 98) –45, 23, 24, 25 (45, 25, 24, 23) –26, 27 (26, 27)
25
FSCAN Maintain two sub-queues Maintain two sub-queues While servicing one sub-queue, add new requests to the other. While servicing one sub-queue, add new requests to the other. Service of new requests deferred until all old requests have been processed Service of new requests deferred until all old requests have been processed
26
Disk scheduling in Linux
27
Elevator Elevator –Long delays possible. Processes don’t have to wait for writes to complete. Processes don’t have to wait for writes to complete. Three queues (Deadline scheduler) Three queues (Deadline scheduler) –Elevator (sorted) –Write requests (expiration time = 5s) –Read requests (expiration time = 0.5s) Anticipatory scheduler Anticipatory scheduler –After every read request servicing, wait a short duration to see if there is another read request from the same region is made. If yes, service it immediately.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.