Disk Scheduling in Linux
Disk Scheduling in Linux
Our Problem
Suppose we have multiple requests for disk
blocks . Which should we access first?
Yes, order does matter a lot.
Problem Statement
Input:
A set of requests.
The current disk head location.
Algorithm state (direction??)
Output:
The Goals
Maximize throughput
Operations per second.
Maximize fairness
All disk requests treated equally.
Avoid Starvation
And very very long waits.
Possible Algorithms
Pessimist - Choose the disk request furthest from the current disk
head position.
Optimal - Choose the disk request closest to the current disk head
position.
FCFS - Serve the requests in their arrival order.
Elevator - Move back and forth, solving requests as you go.
Cyclic Elevator - Move toward the bottom, solving requests as you
go.
When youve solved the lowest request, seek all the way to the
highest request.
Anticipatory Scheduling
Concept
Algorithm
Q20
Dispatcher
Filter
Disk Queue
Disk
Deadline
Noop
Anticipatory, and
CFQ
You can see which scheduler you are currently running by using the following
command:
# cat /sys/block/sda/queue/scheduler
noop anticipatory deadline [cfq]
// all or some of them on your linux distribution?
Changing schedulers on the fly allows you to test and benchmark the algorithms
for your specific application.
Once the change is issued, any current I/O operations will be executed before
the new scheduler goes into effect, so the change will not be instantaneous.
Algorithm Analysis
Optimal
FCFS
Performance good
Fair, but files near the middle of the disk get more attention.
Deadline Scheduler
Anticipatory Scheduling
CFQ
Has Real Time support. Fair.
No starvation is possible. Allows for priorities.
Benchmarks
In Real Operating Systems
Performance is never obvious.
No one uses the textbook algorithm.
Benchmarking is everything.
Theory is useful, if it helps you benchmark better.
Real time
Sys time
User time