Operating Systems · Disk I/O

Disk Scheduling
From zero to algorithm.

A mechanical arm physically moves to read your data. When ten programs want data at once, the order you serve them changes everything. This page takes you from the hardware up.

FCFS (naive)
640
tracks moved
LOOK (smart)
153
tracks moved

Same 8 requests. No hardware change. Just a smarter order — 76% less movement.

START SCROLLING

step 1 of 8

What is a hard disk, physically?

Step through the machine layer by layer — from the metal casing down to a single sector. Toggle between the 3D view and the top-view platter diagram.

PLATTER

Spins at 5400–7200 RPM. Data stored magnetically on the surface.

TRACKS

Concentric rings numbered 0–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 8

The problem it creates.

Every time the head moves between tracks, it takes real time. With multiple programs all requesting disk data simultaneously, the OS holds a queue of requests — and the order it serves them determines how far the head travels.

Seek time — the one cost we control

Time for the arm to physically move between tracks. Proportional to distance.

seek distance = |current track − target track|
e.g. head at 53, request for 183 → |183 − 53| = 130 tracks

FCFS — NAIVE ORDER — ZIGZAG SEEK PATH

0 199 start: 53

The head zigzags wildly — 183→37 is a 146-track jump that a smarter order would have avoided.

The core problem: serving requests in the wrong order makes the head travel enormous unnecessary distances. Disk scheduling is the OS deciding the right order.

step 3 of 8

So what is disk scheduling?

One definition. Nothing more yet.

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 don't need it

Think of the OS as a dispatcher. The read head is a taxi — it can only be in one place at a time. The dispatcher decides the route through all pending pick-up points to minimise total distance driven.

step 4 of 8

Four terms. That's all you need.

Every algorithm references these. Know them now, read the rest without friction.

SEEK TIME

Head movement time

Time for the arm to move from one track to another. The dominant cost. |from − to|

REQUEST QUEUE

Pending I/O list

Track numbers that processes have requested but not yet been served. The scheduler reorders this.

STARVATION

A request never served

When a request waits indefinitely because the algorithm keeps choosing others. A serious failure mode.

THROUGHPUT

Requests per unit time

How many I/O requests the disk completes in a given time. More = better performance.

// the example used throughout this page

Head starts at: track 53
Request queue: 98, 183, 37, 122, 14, 124, 65, 67
Disk range: 0 – 199

step 5 of 8

The algorithms — one at a time.

Each one fixes a specific flaw in the previous. Read them in order.

FCFS First Come First Served
640 tracks

Rule: Serve requests exactly in the order they arrived. Zero optimisation.

Order: 53→98→183→37→122→14→124→65→67

no starvation simple worst movement convoy effect
SSTF Shortest Seek Time First
236 tracks

Rule: From current position, always pick the nearest pending request next.

Order: 53→65→67→98→122→124→183→37→14

much less movement starvation risk not fair
SCAN Elevator Algorithm
187 tracks

Rule: Sweep one direction serving everything; hit the disk edge; reverse.

Order: 53→65→67→98→122→124→183→199 (edge)→37→14

no starvation fair wastes travel to edge
LOOK ★ Smart Elevator
153 tracks — best

Rule: Like SCAN but stops at the last actual request — no wasted travel to disk edges.

Order: 53→65→67→98→122→124→183→37→14

no starvation efficient no wasted edge travel
C-SCAN

Rule: One-way sweep only. Jump back to track 0 without serving on return. Uniform wait time.

382 tracks

uniform wait higher movement
C-LOOK

Rule: Like C-SCAN but jumps to lowest pending request (not track 0). Best of both worlds.

157 tracks

uniform wait no edge waste
step 6 of 8 — the set piece

Watch the head move.

Same 8 requests. Each algorithm. Step through it — the disk arm and track axis move together so you see both representations of the same seek.

Track 0 Track 199
53
STEP
0 / 0
TOTAL MOVEMENT
0
step 7 of 8

The scoreboard.

Same 8 requests. All 6 algorithms. Side by side.

Algorithm Movement Starvation Best use case
FCFS640NoneLight / simple systems
SSTF236YesLow latency, predictable load
SCAN187NoneHeavy, uniform load
LOOK ★153NoneGeneral purpose best choice
C-SCAN382NoneUniform wait time needed
C-LOOK157NoneUniform + efficient
step 8 of 8 — you've earned this

Now try your own numbers.

You've watched the hardcoded example. You know why LOOK beats FCFS by 76%. Now put in your own queue and test your predictions.

Open the disk scheduler

NO LOGIN · NO INSTALL · RUNS IN BROWSER