Operating Systems · Disk I/O

Disk Scheduling
From zero to algorithm.

A mechanical arm physically moves to read your data. The order you serve competing requests changes everything.

START SCROLLING

step 1 of 7

What is a hard disk, physically?

Step through each component. Toggle between the 3D side view and the top-down platter diagram.

PLATTER

Spins at 5,400 to 7,200 RPM. Data stored magnetically on the surface.

TRACKS

Concentric rings numbered 0 to 199. Every byte lives at a specific track.

READ HEAD

A mechanical arm that physically moves between tracks. One track at a time.

step 2 of 7

The problem it creates.

Order matters. Same 8 requests — two different approaches, radically different outcomes.

FCFS — naive order 640 tracks moved
LOOK — smart order 153 tracks moved

FCFS SEEK PATH — HEAD ZIGZAGS WILDLY

0 199 53 start 53

Seek time: the one cost we control

Physical arm movement time, proportional to distance.

seek distance = |current track - target track| e.g. 53 to 183 = 130 tracks

The problem: wrong order forces enormous unnecessary travel. Disk scheduling is how the OS decides the right order.

step 3 of 7

So what is disk scheduling?

Disk scheduling is the algorithm the OS uses to decide the order in which pending disk I/O requests are served, with the goal of minimising total head movement.

OPTIMISES

Total seek distance

IGNORES

Rotational latency, transfer time

APPLIES TO

HDDs only. SSDs have no moving parts.

REQUESTS QUEUING FOR THE DISK HEAD

DISK
HEAD

Think of it as a taxi dispatcher: one cab, many pick-up points. The dispatcher finds the most efficient route through all of them.

step 4 of 7

Four terms. That is all you need.

Every algorithm references these. Learn them here, read the rest without friction.

Seek Time

Head movement time

Time for the arm to move from one track to another. The dominant cost in HDD performance.

|from - to| in track units
📋

Request Queue

Pending I/O list

Track numbers requested but not yet served. The scheduler reorders this list to minimise movement.

⚠️

Starvation

A request never served

When a far-away request waits indefinitely because the algorithm always picks closer ones first.

Throughput

Requests per unit time

How many I/O requests complete per second. Less seek distance directly means higher throughput.

step 5 of 7

The algorithms, one at a time.

Each one fixes a flaw in the previous. Click a card to expand it.

Head starts at track 53. Requests: 98, 183, 37, 122, 14, 124, 65, 67

FCFS First Come First Served 640 tracks

How it works: Requests are served exactly in arrival order. No consideration of head position at all.

53 to 98(+45) to 183(+85) to 37(+146) to 122(+85) to 14(+108) to 124(+110) to 65(+59) to 67(+2)

Track 0 Track 199
53
STEP
0 / 8
TOTAL MOVEMENT
0
Press Play to step through.
  • +Simple FIFO queue, no extra logic.
  • +No starvation: every request is served in arrival order.
  • +Completely fair across all processes.
  • -Highest head movement of all algorithms.
  • -Convoy effect: one distant request stalls everything behind it.
  • -Ignores head position entirely.
SSTF Shortest Seek Time First 236 tracks

How it works: Always pick the closest pending request to the current head position. Greedy, one move at a time.

53 to 65(+12, nearest) to 67(+2) to 98(+31) to 122(+24) to 124(+2) to 183(+59) to 37(+146) to 14(+23)

Track 0 Track 199
53
STEP
0 / 8
TOTAL MOVEMENT
0
Press Play to step through.
  • +Much lower movement than FCFS (236 vs 640 tracks).
  • +Better average response time for nearby requests.
  • +Improved throughput over FCFS.
  • -Starvation: far tracks may wait indefinitely.
  • -High variance in response times across requests.
  • -Greedy per step, not globally optimal.
SCAN Elevator Algorithm 187 tracks

How it works: Sweep in one direction serving everything encountered. On reaching the disk edge, reverse and sweep back.

53 to 65 to 67 to 98 to 122 to 124 to 183 to 199 (disk edge) to 37 to 14

Track 0 Track 199
53
STEP
0 / 9
TOTAL MOVEMENT
0
Press Play to step through.
  • +No starvation: every request is served each sweep.
  • +More uniform wait times than SSTF.
  • +Better throughput than FCFS with fairness intact.
  • -Travels to disk edge even when no requests exist there.
  • -Middle tracks served more often than edge tracks.
  • -A request just missed must wait a full reverse sweep.
LOOK Smart Elevator 153 tracks (best)

How it works: Like SCAN, but reverses at the last actual request in each direction, not the disk edge. No wasted travel.

53 to 65 to 67 to 98 to 122 to 124 to 183 (reverses) to 37 to 14

Track 0 Track 199
53
STEP
0 / 8
TOTAL MOVEMENT
0
Press Play to step through.
  • +Lowest total head movement in this example (153 tracks).
  • +No starvation: all requests served within two sweeps.
  • +Eliminates wasted edge travel compared to SCAN.
  • -Slightly more complex than SCAN to implement.
  • -Requests just behind the reversal point wait a full sweep.
  • -Centre tracks still served marginally more than edges.
step 6 of 7

The scoreboard.

Same 8 requests. All four algorithms. Shorter bar is better.

Algorithm Movement Starvation When to use it
FCFS 640 None Very short queues where arrival-order correctness matters more than performance.
SSTF 236 Yes Workloads with strong locality; requests clustered in one track region.
SCAN 187 None High-throughput servers with requests spread across the full disk range.
LOOK 153 None Best general-purpose choice. Preferred over SCAN when requests don't fill the full disk range.
step 7 of 7

Now try your own numbers.

Put in your own queue and test your predictions.

Open the disk scheduler

NO LOGIN. NO INSTALL. RUNS IN BROWSER.