Exercises — Disk scheduling — FCFS, SCAN, C-SCAN, LOOK
A quick reminder of the number line we live on for the first block of problems:

Level 1 — Recognition
Exercise 1.1 (L1)
For each description, name the algorithm: FCFS, SCAN, C-SCAN, or LOOK.
(a) "Serve requests strictly in the order they arrived." (b) "Sweep one way, hit the physical edge (0 or max), reverse, serve the rest." (c) "Sweep one way to the last request only, then reverse — never touch the physical edge." (d) "Sweep one way, jump back to the far extreme without serving, sweep the same way again."
Recall Solution 1.1
(a) FCFS — no reordering at all. (b) SCAN — the elevator that hits the wall. (c) LOOK — it only "peeks" as far as the last request. (d) C-SCAN — the one-way circular escalator.
Why: the only thing that separates these is (i) whether they reorder, (ii) whether they touch the physical boundary, and (iii) whether they serve on the return trip. That triple fully classifies the family.
Exercise 1.2 (L1)
The head is at cylinder 50 and the next request served is cylinder 90. How many cylinders of head movement does this single move cost?
Recall Solution 1.2
One move costs cylinders. That is literally one term of the sum in the formula — nothing more.
Level 2 — Application
Standard setup for this whole level: Queue (arrival order): 82, 170, 43, 140, 24, 16, 190 Head start . Disk range: 0–199. Direction: up (toward larger cylinders) first. Sorted for reference: 16, 24, 43, 82, 140, 170, 190.
Exercise 2.1 (L2) — FCFS
Compute total head movement under FCFS.
Recall Solution 2.1
WHAT: walk the queue in arrival order, no sorting. Order: . WHY the big numbers: the and jumps are the head bouncing across the whole disk — the signature waste of FCFS.
Exercise 2.2 (L2) — SCAN
Compute total head movement under SCAN (up first, disk end = 199).
Recall Solution 2.2
WHAT: go up serving everyone, touch 199, reverse, serve the rest down. Up path: . Down path: . Up movement: . Down movement: . WHY 199 appears twice implicitly: we travel to 199 (part of the 149) and from 199 (part of the 183). SCAN pays the full trip to the wall even though no request sits at 199.
Exercise 2.3 (L2) — LOOK
Same setup under LOOK.
Recall Solution 2.3
WHAT: identical order, but stop at the last actual up-request (190), never reach 199. Up: . Down: . Up movement: . Down movement: . Check against SCAN: SCAN's extra cost is , and indeed . ✔
Level 3 — Analysis
Setup for this level: Queue: 98, 183, 37, 122, 14, 124, 65, 67 · Head: 53 · Range: 0–199. (This is the parent note's standard example — reuse its known answers to check yourself.)
Exercise 3.1 (L3) — Direction matters
The parent computed SCAN up-first = 331. Now compute SCAN down-first (head moves toward cylinder 0 first, touches 0, then reverses up). Which direction is cheaper here, and why?
Recall Solution 3.1
Sorted: 14, 37, 65, 67, 98, 122, 124, 183. Down first: , then up: . Down movement: . Up movement: . Compare: up-first SCAN , down-first SCAN . Down-first is cheaper by . WHY: the head at 53 is much closer to the bottom edge (0) than the top edge (199). Going toward the near wall first wastes far less on reaching the boundary. Direction is not cosmetic — it can swing the answer by ~30%.
Exercise 3.2 (L3) — C-SCAN with vs without the wrap counted
Compute C-SCAN (up first) two ways: (a) counting the wrap-around jump , (b) ignoring the wrap (some textbooks do). State both totals.
Recall Solution 3.2
Up: , then jump , then up: .
- Up to end: .
- Wrap jump: .
- Resume up to last: .
(a) With wrap: . (b) Without wrap: . WHY the ambiguity: the wrap is a real physical head movement, so counting it (382) is the honest total-travel number. But some courses treat the return as "instantaneous repositioning" and drop it (183). Always state your convention — the grader wants to see which you assumed.
Exercise 3.3 (L3) — C-LOOK
Compute C-LOOK (up first) with the wrap counted, for the same queue/head. Compare to C-SCAN(a).
Recall Solution 3.3
C-LOOK stops at the last up-request (183) and jumps back to the lowest request (14), not to 0. Up: , jump , then up: .
- Up to last: .
- Jump back: .
- Resume up: .
Compare C-SCAN(a) : C-LOOK saves by avoiding the empty stretches (top) and (bottom). Precisely . ✔
Level 4 — Synthesis
Exercise 4.1 (L4) — Rank them all
For queue 98, 183, 37, 122, 14, 124, 65, 67, head 53, up-first, range 0–199, list FCFS / SCAN / LOOK / C-SCAN(with wrap) / C-LOOK(with wrap) totals and rank from least to most head movement.
Recall Solution 4.1
From the parent note and Exercises 3.2–3.3:
- FCFS
- SCAN
- LOOK
- C-SCAN (wrap)
- C-LOOK (wrap)
Ranking (least → most travel): WHY this order makes sense: the elevators (LOOK/SCAN) beat FCFS by killing zig-zag. Within elevators, "no boundary trip" (LOOK) beats "boundary trip" (SCAN), and the circular versions add wrap cost. FCFS is worst because it ignores geometry entirely.
Visual summary of the ranking:

Exercise 4.2 (L4) — Build a worst case for FCFS
Design a request queue of exactly 4 requests (head at 100, range 0–199) that makes FCFS's total head movement as large as possible. What is that maximum, and what ordering achieves it?
Recall Solution 4.2
WHAT to exploit: FCFS pays for each consecutive pair, so we want each consecutive pair to span the full disk, alternating extremes. Queue: (head starts at 100). WHY this is (near) maximal: after the first move lands on an extreme, every later move is a full-width swing. The only "waste-limited" term is the first (, because the head started in the middle). Starting the head at an extreme instead (say 0) would give , the true maximum for 4 full-swing requests. Lesson: FCFS's worst case is bounded only by how adversarial the arrival order is — this is exactly why smarter scheduling exists.
Level 5 — Mastery
Exercise 5.1 (L5) — Prove the SCAN vs LOOK gap
Head starts at , moves up first. Let be the largest requested cylinder () and the smallest requested cylinder (), with disk range . Prove that (Assume there is at least one request below , so both algorithms reverse and sweep down to .)
Recall Solution 5.1
LOOK (up first): go up to the last request , then down to the smallest . SCAN (up first): go up all the way to , then down to . Subtract: WHY it's exactly this and nothing else: the down-portion of both trips ends at the same ; the only difference is how high the head climbed before reversing — vs — and that overshoot is paid twice (once going up, once coming back down through it). The start cancels because both algorithms leave from the same place. This is the algebra behind the parent note's rule "difference ."
Exercise 5.2 (L5) — Latency-aware decision
A disk with range 0–199 has this pending queue (head at 100): 101, 102, 103, 0, 199. Rotational latency is negligible; seek dominates. A real-time request at cylinder 199 must be served within a movement budget of 120 cylinders or it misses its deadline. Under SCAN up-first, does cylinder 199 make its deadline? Under FCFS (arrival order as listed)? Which policy should the OS pick for this deadline, and what does it cost in total travel?
Recall Solution 5.2
SCAN up-first: (then down ). Movement to reach 199: cylinders ✔ — deadline met. Total SCAN travel: up , down → .
FCFS (order 101, 102, 103, 0, 199): the head visits . Movement to reach 199 = sum of all prior legs plus the last: (The detour down to 0 before 199 blows the budget.) Total FCFS travel here .
Decision: choose SCAN (up-first). It meets the 199 deadline (99 ≤ 120) and has lower total travel (298 < 305). Here the elevator wins on both axes — but the general point (see I/O Subsystem and Device Drivers) is that real schedulers weigh deadlines, not just the raw sum.
Recall One-line self-test recap
LOOK ≤ SCAN by 2×(end−last) ::: proven in 5.1 FCFS never reorders ::: even if sorting would help (2.1 trap) C-SCAN pays a wrap jump for fairness ::: 382 with wrap vs 183 without (3.2) Direction can change SCAN's total a lot ::: 331 up-first vs 236 down-first (3.1) "Best" needs a metric ::: total travel vs fairness vs deadline (4.1 trap, 5.2)
Connections
- 4.2.38 Disk scheduling — FCFS, SCAN, C-SCAN, LOOK (Hinglish)
- Seek time vs Rotational latency
- Hard Disk Drive structure (cylinders, tracks, sectors)
- Process Scheduling — FCFS, SJF, Round Robin
- Starvation and Fairness in OS
- SSTF (Shortest Seek Time First)
- I/O Subsystem and Device Drivers