9.2 FCFS & Shortest Seek Time First (SSTF) Disk Scheduling
💡 Core Intuition
🍳 The Everyday Analogy: The City Courier Delivery Route
Imagine an express motorcycle courier with 8 packages to deliver across a 200-block avenue:
The Courier Routing Strategy Pipeline
Contrasting order-of-call dispatching with proximity-first optimization
Deliver in Order of Phone Calls
Call 1 came from Block 98, Call 2 from Block 183, Call 3 from Block 14.
Deliver to Nearest Customer First
At Block 53, the driver checks their GPS: 'Who is closest to where I am standing right now?'
Customer at Block 183 Forgotten
If new orders keep arriving at downtown blocks 50–70, the customer at Block 183 starves forever.
- FCFS: Fair and starvation-free, but causes erratic back-and-forth arm thrashing.
- SSTF: Minimizes seek movements locally via greedy proximity, but can cause peripheral requests to starve indefinitely.
💻 Bridging to Computer Science
When a system runs multiple concurrent processes, read and write requests accumulate in the Disk Request Queue.
Because moving the physical read/write head (Seek Time) is by far the most expensive operation in secondary storage (), the operating system must reorder pending requests to minimize the total head traversal distance (measured in total cylinders traversed).
📚 Core Deep-Dive & Concepts
1. First-Come, First-Served (FCFS) Scheduling
Algorithm Mechanics
- Services I/O requests strictly in the order they arrive in the device queue.
- Operates as a simple FIFO queue of cylinder numbers.
- Imposes zero computational sorting overhead.
Mathematical Trace: FCFS
Given the initial head position at Cylinder 53 and the request queue:
FCFS Disk Head Trajectory
Erratic actuator arm oscillations across disk cylinders: 53 → 98 → 183 → 37 → 122 → 14 → 124 → 65 → 67
| Step | From Cylinder | To Target Cylinder | Traversal Formula | Distance Moved | Cumulative Movement |
|---|---|---|---|---|---|
| 1 | 53 | 98 | $ | 98 - 53 | $ |
| 2 | 98 | 183 | $ | 183 - 98 | $ |
| 3 | 183 | 37 | $ | 37 - 183 | $ |
| 4 | 37 | 122 | $ | 122 - 37 | $ |
| 5 | 122 | 14 | $ | 14 - 122 | $ |
| 6 | 14 | 124 | $ | 124 - 14 | $ |
| 7 | 124 | 65 | $ | 65 - 124|$ | 59 |
| 8 | 65 | 67 | $ | 67 - 65|$ | 2 |
Architectural Evaluation: FCFS
- Advantages:
- Trivial to implement.
- Intrinsically fair: every request is guaranteed service in finite time.
- Zero Starvation.
- Disadvantages:
- Wild, erratic head swings across the disk surface (e.g. from down to , then up to , then down to ).
- Results in abysmal I/O throughput and long average response times.
2. Shortest Seek Time First (SSTF) Scheduling
Algorithm Mechanics
- Selects the request with the minimum seek distance from the current head position:
- Operates analogously to Shortest Job First (SJF) in CPU scheduling.
- A greedy heuristic designed to maximize instantaneous I/O throughput.
3. Step-by-Step Mathematical Trace: SSTF
- Initial Head Position:
53 - Remaining Queue:
[ 98, 183, 37, 122, 14, 124, 65, 67 ]
SSTF Disk Head Trajectory
Greedy proximity seeking slashes travel: 53 → 65 → 67 → 37 → 14 → 98 → 122 → 124 → 183
| Step | Current Head | Remaining Candidates in Queue | Distances | Minimum Selected | Distance Moved | | :---: | :---: | :---: | :---: | :---: | :---: | | 1 | 53 | 98, 183, 37, 122, 14, 124, 65, 67 | 98 (45), 37 (16), 65 (12), 67 (14) | 65 | | | 2 | 65 | 98, 183, 37, 122, 14, 124, 67 | 67 (2), 98 (33), 37 (28) | 67 | | | 3 | 67 | 98, 183, 37, 122, 14, 124 | 37 (30), 98 (31), 122 (55) | 37 | | | 4 | 37 | 98, 183, 122, 14, 124 | 14 (23), 98 (61) | 14 | | | 5 | 14 | 98, 183, 122, 124 | 98 (84), 122 (108), 124 (110), 183 (169) | 98 | | | 6 | 98 | 183, 122, 124 | 122 (24), 124 (26), 183 (85) | 122 | | | 7 | 122 | 183, 124 | 124 (2), 183 (61) | 124 | | | 8 | 124 | 183 | 183 (59) | 183 | |
Performance Comparison on Benchmark:
- FCFS Head Movement: Cylinders
- SSTF Head Movement: Cylinders
- Improvement: reduction in actuator arm travel!
4. Comprehensive Comparison Matrix
🏭 In The Real World: Production Case Study
Database Log Flushing & Sequential Write Optimization
In high-write enterprise databases (such as PostgreSQL Write-Ahead Logging WAL or Cassandra CommitLogs), random seek times destroy transaction commit throughput:
- Why SSTF is Dangerous for General Purpose Workloads:
- In desktop and server operating systems, a batch of requests reading a file in cylinder 50 can indefinitely stall a critical user click trying to load a binary from cylinder 190.
- The Modern Evolution:
- Because SSTF introduces starvation, modern production kernels evolved toward Elevator Algorithms (SCAN, C-SCAN, and LOOK), which achieve near-SSTF throughput while mathematically eliminating starvation!
🎯 Exam & Interview Pitfall Check
Question 1: Why is SSTF scheduling considered a greedy algorithm, and why does it NOT guarantee the globally optimal total seek time? Answer:
- SSTF is greedy because at every step it makes the locally optimal choice—selecting the candidate cylinder closest to the current head position without considering future arrivals or the global path.
- It does not guarantee the global minimum seek time. For example, moving to a nearby cylinder might leave the head stranded near one edge of the disk, requiring a massive full-stroke sweep later. A different initial choice might have allowed the arm to sweep past multiple cylinders monotonically, yielding a lower aggregate total.
Question 2: Under what workload condition does SSTF degenerate into severe starvation? Answer:
- SSTF causes starvation when a continuous stream of I/O requests arrives for tracks near the current head position.
- The algorithm will continuously satisfy these newly arriving nearby requests, keeping the actuator arm tethered to that local zone.
- Any request located far away on an outer or inner cylinder track will sit in the queue indefinitely, suffering unbounded starvation.
- The Tie-Breaking Distance Trap: At step 3 of the SSTF trace from cylinder , candidate has distance , while candidate has distance . Students frequently pick by guessing that higher numbers are closer. Always calculate absolute numerical differences: !
- The "SSTF Eliminates Seek Time" Fallacy: SSTF minimizes head movement compared to FCFS, but seek time is still required. Only sequential contiguous allocations on the same cylinder achieve true zero-seek performance.