5 Disk Scheduling
5 Disk Scheduling
5 Disk Scheduling
William M. Mongan
Maxim Shevertalov
Jay Kothari
*This lecture was derived from material in the Operating System
Concepts, 8th Edition textbook and accompanying slides. Contains
Copyrighted Material
Some slides adapted from the text and are copyright: 2009 Silbershatz, Galvin
and Gagne, All Rights Reserved
• Maximize Throughput
• Maximize operations (or jobs) per second
• Throughput related to response time, but not identical:
» Minimizing response time will lead to more context switching than if you only maximized
throughput
• Two parts to maximizing throughput
» Minimize overhead (for example, context-switching)
» Efficient use of resources (CPU, disk, memory, etc)
• Fairness
• Share CPU among users in some equitable way
• Fairness is not minimizing average response time:
» Better average response time by making system less fair
Lec 5 Operating Systems 2
Recap: Scheduling (1)
• Scheduling: selecting a waiting process from the ready
queue and allocating the CPU to it
• FCFS Scheduling
• Round-Robin Scheduling
• Lottery Scheduling
• What do we want?
• Magnetic tape
– Was early secondary-storage medium
– Relatively permanent and holds large quantities of data
– Access time slow
– Random access ~1000 times slower than disk
– Mainly used for backup, storage of infrequently-used data,
transfer medium between systems
– Kept in spool and wound or rewound past read-write head
– Once data under head, transfer rates comparable to disk
– 20-200GB typical storage
– Common technologies are 4mm, 8mm, 19mm, LTO-2 and
SDLT
• Response Time =
H a
b k
c
j
d
h f
g
e
i
Head pointer 53
• Version of C-SCAN
• Arm only goes as far as the last request in each
direction, then reverses direction immediately,
without first going all the way to the end of the disk
http://linuxkernel2.atw.hu/ch13lev1sec5.html
Linux Scheduling Algorithms
• Noop Scheduler
– Basic FCFS scheduler – all it does is keep the requests
sorted by sector number
– Good for random-access block devices
• Completely Fair Queuing (CFQ)
– Sort by sector number, but maintain process-level fairness by
keeping a separate sorted queue for each process
– Service those queues round robin, with a quantum (ensures
that each process will be served I/O every so often, i.e. for
buffering purposes)
• The Linus Elevator
– Sort by sector number, but check to see if some requests are
getting starved (aging)
• If so, queue the request at the end, not in sorted order
http://linuxkernel2.atw.hu/ch13lev1sec5.html
Linux Scheduling Algorithms
• Deadline Scheduling
– Reads block processes, as opposed to writes (typically), so
mandate that reads be served within 500 ms, and writes
within 5 seconds
• If something expires, start serving those requests in sorted order
• Otherwise, keep 3 queues: reads, writes, sorted order
• Anticipatory Scheduling
– Same as above, but wait ~6ms for new requests to maintain
the sort
– Risky (could lose that time if no new requests), but we hedge
our bets by playing the numbers (due to locality)
http://linuxkernel2.atw.hu/ch13lev1sec5.html
Disk Management
• I/O Hardware
• Application I/O Interface
• Kernel I/O Subsystem
• Transforming I/O Requests to Hardware Operations
• STREAMS
• Performance
Synchronou Asynchronous
s
• Scheduling
– Some I/O request ordering via per-device queue
– Some OSs try fairness
mirroring/Shadowing
– Most Expensive D0 D1 D2 D3 P0
– Bandwidth sacrifice: 1 write =
D4 D5 D6 P1 D7
2
– To recover simply swap out a D8 D9 P2 D10 D11
disk, can be hot swappable
• RAID 5+: High I/O Rate D12 P3 D13 D14 D15
Parity
– Stripped across multiple disks
P4 D16 D17 D18 D19
P0 = D0 ⊗ D1 ⊗ D2 ⊗ D3