📖 Definition: Disk scheduling algorithms determine the order in which disk I/O requests are serviced to minimize seek time and maximize disk throughput.
⚠️ Common Example Setup (used in all algorithms below):
Head starts at: 53
Request Queue: 98, 183, 37, 122, 14, 124, 65, 67
Disk range: 0 to 199
Algorithm 1 — FCFS (First Come First Served)
📖 FCFS: Service requests in the order they arrive. Simplest algorithm — no starvation but may result in a lot of head movement.
💡 FCFS Example:
Head starts at 53
Order: 53→98→183→37→122→14→124→65→67
Movement:
53 → 98 = 45
98 → 183 = 85
183 → 37 = 146
37 → 122 = 85
122 → 14 = 108
14 → 124 = 110
124 → 65 = 59
65 → 67 = 2
─────────────
Total = 640 cylinders
❌ Disadvantage: Does not optimize head movement. Wild swings across disk → poor performance.
Algorithm 2 — SSTF (Shortest Seek Time First)
📖 SSTF: Service the request closest to current head position. Like SJF for disks — always pick nearest request.
💡 SSTF Example:
Head starts at 53
Queue: 98, 183, 37, 122, 14, 124, 65, 67
Step 1: Closest to 53 → 65 (dist=12) → move to 65
Step 2: Closest to 65 → 67 (dist=2) → move to 67
Step 3: Closest to 67 → 37 (dist=30) → move to 37
Step 4: Closest to 37 → 14 (dist=23) → move to 14
Step 5: Closest to 14 → 98 (dist=84) → move to 98
Step 6: Closest to 98 → 122 (dist=24) → move to 122
Step 7: Closest to 122→ 124 (dist=2) → move to 124
Step 8: Closest to 124→ 183 (dist=59) → move to 183
─────────────────────────────────────────
Order: 53→65→67→37→14→98→122→124→183
Total = 236 cylinders (Much better than FCFS!)
❌ Disadvantage: Starvation possible — requests far from current head may wait forever if closer requests keep arriving.
Algorithm 3 — SCAN (Elevator Algorithm)
📖 SCAN: Disk arm moves in one direction servicing all requests until it reaches end of disk, then reverses direction. Like an elevator going up then down.
💡 SCAN Example (moving towards higher):
Head starts at 53, moving towards higher numbers
Queue: 98, 183, 37, 122, 14, 124, 65, 67
Moving UP (towards 199):
53→65→67→98→122→124→183→199 (end)
Then reverses, moving DOWN:
199→37→14→0
Order: 53→65→67→98→122→124→183→37→14
Total = (183-53) + (183-14) = 130 + 169 = 299 cylinders
Visual:
0 14 37 53 65 67 98 122 124 183 199
|────|────|───|───|──|─────|───|───|───────|──────|
◄────────── │ ─────────────────────►
Start
✅ No starvation — every request eventually served.
Algorithm 4 — C-SCAN (Circular SCAN)
📖 C-SCAN: Like SCAN but only services requests while moving in ONE direction (usually high to low). When it reaches end, it jumps back to beginning without servicing any requests on return. More uniform wait time than SCAN.
💡 C-SCAN Example:
Head at 53, moving towards higher numbers
Queue: 98, 183, 37, 122, 14, 124, 65, 67
Moving UP: 53→65→67→98→122→124→183→199
Jump to 0 (no service on return)
Moving UP again: 0→14→37
Order: 53→65→67→98→122→124→183→199→0→14→37
Visual:
0 14 37 53 65 67 98 122 124 183 199
|────|────|───|───|──|─────|───|───|───────|──────|
──►──┤ ┤ ├──────────────────────────────►
(return) (continue here next cycle)
Algorithm 5 — LOOK
📖 LOOK: Like SCAN, but arm only goes as far as the last request in each direction — does NOT go all the way to end of disk. More efficient than SCAN.
💡 LOOK Example:
Head at 53, moving towards higher numbers
Queue: 98, 183, 37, 122, 14, 124, 65, 67
Moving UP (only to 183, NOT to 199):
53→65→67→98→122→124→183
Reverse, moving DOWN (only to 14, NOT to 0):
183→37→14
Order: 53→65→67→98→122→124→183→37→14
Total = (183-53) + (183-14) = 130+169 = 299 cylinders
(Same movement but doesn't go to 199 or 0)
Algorithm 6 — C-LOOK
📖 C-LOOK: Combination of C-SCAN and LOOK. Services requests in one direction only up to last request, then jumps back to first request (not beginning of disk). Most efficient in practice.
💡 C-LOOK Example:
Head at 53, moving towards higher numbers
Queue: 98, 183, 37, 122, 14, 124, 65, 67
Moving UP (to last request = 183):
53→65→67→98→122→124→183
Jump back to FIRST request (14), not 0:
183 → 14 (jump, no service)
Continue UP: 14→37
Order: 53→65→67→98→122→124→183→14→37
Total = (183-53) + (183-14) = 130+169 = 299 cylinders
| Algorithm |
Movement |
Starvation |
Total (Example) |
Best For |
| FCFS |
Request order |
No |
640 |
Light load |
| SSTF |
Nearest first |
Yes |
236 |
Performance |
| SCAN |
Both directions, full sweep |
No |
299 |
Heavy load |
| C-SCAN |
One direction, jump back |
No |
~382 |
Uniform wait |
| LOOK |
Both directions, to last request |
No |
299 |
Better than SCAN |
| C-LOOK |
One direction, jump to first |
No |
~322 |
Best practical |