Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data...
-
date post
19-Dec-2015 -
Category
Documents
-
view
214 -
download
0
Transcript of Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data...
I/O devices
Vary in many ways– Data rate– Application– Complexity of control– Unit of transfer– Data representation– Error conditions
Categories of devices that engage in I/O Human readable e.g. printer,
mouse Machine readable e.g. tape, disk Communication devices e.g.
modem
Organization of the I/O function Programmed I/O
– Program busy-waits while waiting for I/O device to respond.
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.
Organization of the I/O function Direct Memory Access
– Uses interrupts to communicate with the processor.
– Assists with transfer of large amounts of data.
DMA
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 does other work. 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.
Operating system requirements to handle I/O devices Efficiency
– I/O devices are slow.– Use multi-programming.– Suspend processes.
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.
Disk scheduling
To read or write, the disk head must be positioned at the desired track and at the beginning of the desired sector
Seek time– time it takes to position the head at the
desired track Initial startup time Time to traverse tracks
Rotational delay or rotational latency– time its takes for the beginning of the
sector to reach the head
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.
Disk scheduling aims at reducing the traversal time.
Number of tracks = 200 Current position of head is track 100Request sequence: 55,58,39,18,90,160,150,38,184
FIFO
Priority
Decision made outside of the disk management software.
Give priority to shorter jobs, interactive jobs.
Last In First Out
Satisfy the most recent request. In systems that do sequential
processing, will require less arm movement.
Could result in starvation.
Shortest Service Time First Least movement of the disk arm
from its current position Starvation possible
Number of tracks = 200 Current position of head is track 100Request sequence: 55,58,39,18,90,160,150,38,184
SCAN (Elevator)
Eliminate starvation Move the arm in one direction, until
there are no more tracks or no more requests in that direction (LOOK)
Reverse direction and repeat Does not exploit locality.
– Biased against the most recently used tracks.
Favors the innermost and outermost tracks.
Number of tracks = 200 Current position of head is track 100Request sequence: 55,58,39,18,90,160,150,38,184
C-SCAN (Circular)
Service requests only in one direction. (Use LOOK to stop)
Reduces the maximum delay experienced by new requests.
N-step-SCAN
Arm-stickiness occurs with SCAN and C-SCAN
Split the queue into smaller queues of length N
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.
Example
Requests– 2,98,55,34,45,23,24,25,26,27,….
(Scheduled with SCAN)– 2, 23, 24, 25, 26, 27,……, 34, 45, 55,
98 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)
FSCAN
Maintain two sub-queues While servicing one sub-queue,
add new requests to the other. Service of new requests deferred
until all old requests have been processed
Disk scheduling in Linux Elevator
– Long delays possible. Processes don’t have to wait for writes to
complete. Three queues (Deadline scheduler)
– Elevator (sorted)– Write requests (expiration time = 5s)– Read requests (expiration time = 0.5s)
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.