Top Banner
Day 30 I/O Management and Disk Scheduling
27

Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Day 30I/O Management and Disk Scheduling

Page 2: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

I/O devices

Vary in many ways– Data rate– Application– Complexity of control– Unit of transfer– Data representation– Error conditions

Page 3: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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

Page 4: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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.

Page 5: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Organization of the I/O function Direct Memory Access

– Uses interrupts to communicate with the processor.

– Assists with transfer of large amounts of data.

Page 6: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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.

Page 7: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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.

Page 8: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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

Page 9: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.
Page 10: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.
Page 11: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.
Page 12: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

http://computer.howstuffworks.com/hard-disk5.htm

Page 13: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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.

Page 14: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Number of tracks = 200 Current position of head is track 100Request sequence: 55,58,39,18,90,160,150,38,184

FIFO

Page 15: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Priority

Decision made outside of the disk management software.

Give priority to shorter jobs, interactive jobs.

Page 16: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Last In First Out

Satisfy the most recent request. In systems that do sequential

processing, will require less arm movement.

Could result in starvation.

Page 17: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Shortest Service Time First Least movement of the disk arm

from its current position Starvation possible

Page 18: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Number of tracks = 200 Current position of head is track 100Request sequence: 55,58,39,18,90,160,150,38,184

Page 19: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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.

Page 20: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Number of tracks = 200 Current position of head is track 100Request sequence: 55,58,39,18,90,160,150,38,184

Page 21: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

C-SCAN (Circular)

Service requests only in one direction. (Use LOOK to stop)

Reduces the maximum delay experienced by new requests.

Page 22: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.
Page 23: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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.

Page 24: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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)

Page 25: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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

Page 26: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

Disk scheduling in Linux

Page 27: Day 30 I/O Management and Disk Scheduling. I/O devices Vary in many ways Vary in many ways –Data rate –Application –Complexity of control –Unit of transfer.

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.