Disk Scheduling Old
Disk Scheduling Old
Don Porter
Portions courtesy Emmett Witchel
1
COMP 530: Operating Systems
Quick Recap
• CPU Scheduling
– Balance competing concerns with heuristics
• What were some goals?
– No perfect solution
• Today: Block device scheduling
– How different from the CPU?
– Focus primarily on a traditional hard drive
– Extend to new storage media
COMP 530: Operating Systems
Disk Model
Each block on
a sector
1 0
Disk
2 7 Head
3 6
Disk spins at a 4 5
Disk Model
Concentric
tracks
9 8 21 Disk
10 1 0 20
11 2 7 19 Head
12 3 6 18
4 5 17
13
14 15 16
Disk head seeks to
different tracks
Gap between 7
and 8 accounts for
seek time
COMP 530: Operating Systems
Many Tracks
Disk
Head
COMP 530: Operating Systems
Platters spin
Each platter has a head;
together at same
All heads seek together
speed
COMP 530: Operating Systems
Real Example
• Seagate 73.4 GB Fibre Channel Ultra 160 SCSI disk
• Specs:
Ø 12 Arms
– 12 Platters
Ø 14,100 Tracks
– 24 Heads
Ø 512 bytes/sector
– Variable # of sectors/track
– 10,000 RPM
• Average latency: 2.99 ms
– Seek times
• Track-to-track: 0.6/0.9 ms
• Average: 5.6/6.2 ms
• Includes acceleration and settle time.
3 Key Latencies
• I/O delay: time it takes to read/write a sector
• Rotational delay: time the disk head waits for the
platter to rotate desired sector under it
– Note: disk rotates continuously at constant speed
• Seek delay: time the disk arm takes to move to a
different track
COMP 530: Operating Systems
Observations
• Latency of a given operation is a function of current
disk arm and platter position
• Each request changes these values
• Idea: build a model of the disk
– Maybe use delay values from measurement or manuals
– Use simple math to evaluate latency of each pending
request
– Greedy algorithm: always select lowest latency
COMP 530: Operating Systems
Example formula
• s = seek latency, in time/track
• r = rotational latency, in time/sector
• i = I/O latency, in seconds
150 147 72
83 72
83 14 16
To:
C-SCAN: 265 tracks (vs. 221 for SSTF, 187 for SCAN)
COMP 530: Operating Systems
Scheduling Checkpoint
• SCAN seems most efficient for these examples
– C-SCAN offers better fairness at marginal cost
– Your mileage may vary (i.e., workload dependent)
• File systems would be wise to place related data
”near” each other
– Files in the same directory
– Blocks of the same file
• You will explore the practical implications of this
model in Lab 4!
21
COMP 530: Operating Systems
Disk Partitioning
• Multiple file systems can share a disk: Partition space
• Disks are typically partitioned to minimize the maximum seek time
– A partition is a collection of cylinders
– Each partition is a logically separate disk
Partition A Partition B
COMP 530: Operating Systems
24
COMP 530: Operating Systems
1 2 3
OS disk
block
8 9 10 11
12 13 14 15 8 9 10 11 12 13 14 15 0 1 2 3
0 1 2 3
RAID 1: Mirroring
• To increase the reliability of the disk,
redundancy must be introduced
– Simple scheme: disk mirroring (RAID-1)
– Write to both disks, read from either.
x x
x x x x x
x x x x x
Block 1Block
111 0 0a0 0 0 0d1 1 0 1g0 1 1 0j0 1
1 x+1
111 1 1b1 1 0 0e1 1 0 1h0 1 0 1k1 0
x+1 0Parity
000 0 0c0 0 0 0f1 1 0 1i0 1 0 1l1 0
29
COMP 530: Operating Systems
Summary
• Understand disk performance model
– Will explore more in Lab 5 (maybe?)
• Understand I/O scheduling algorithms
• Understand RAID
32