๐Ÿ–ฒ๏ธOperating Systems

Disk Scheduling Algorithms

Study smarter with Fiveable

Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.

Get Started

Why This Matters

Disk scheduling algorithms sit at the intersection of hardware constraints and software optimization. The mechanical reality of spinning platters and moving read/write heads creates a bottleneck that clever algorithms must navigate. You're being tested on your understanding of seek time minimization, fairness vs. efficiency tradeoffs, and starvation prevention.

These algorithms also demonstrate a fundamental OS design principle: there's no perfect solution, only tradeoffs. Each algorithm sacrifices something (fairness, simplicity, or optimal seek time) to gain something else. When you encounter these on an exam, don't just memorize how each works. Know why you'd choose one over another and what problems each solves or creates.


Simple Queue-Based Scheduling

The most intuitive approach treats disk requests like a line at a store: first in, first out. This provides maximum fairness but ignores the physical reality of disk geometry.

First-Come, First-Served (FCFS)

  • Processes requests in arrival order with no consideration of head position or seek distance
  • The convoy effect occurs when short requests queue behind long seeks, degrading throughput for everyone
  • Fairness is guaranteed, but performance suffers under heavy load; best suited for light, predictable workloads

Example: Suppose the head is at cylinder 50 and the request queue is [82, 170, 43, 140, 24, 16, 190]. FCFS processes them in exactly that order. The head bounces back and forth across the disk, racking up a large total seek distance, but every request gets served in the order it arrived.


Greedy Optimization Approaches

These algorithms prioritize minimizing immediate seek time by choosing the "closest" request next. They boost throughput but introduce fairness problems.

Shortest Seek Time First (SSTF)

  • Selects the request nearest to the current head position, minimizing per-request seek time
  • Starvation risk is significant: requests at the far edges of the disk may wait indefinitely as closer requests keep arriving in the middle
  • Analogous to Shortest Job First (SJF) in CPU scheduling, with the same efficiency gains and the same fairness tradeoffs

Compare: FCFS vs. SSTF are both conceptually simple, but FCFS guarantees fairness while SSTF optimizes for throughput. If an exam question asks about starvation, SSTF is your go-to example; if it asks about the convoy effect, think FCFS.


Elevator-Style Algorithms

These algorithms impose directional discipline on head movement, sweeping across the disk like an elevator moves through floors. This reduces erratic back-and-forth motion while providing more predictable wait times than SSTF.

SCAN (Elevator Algorithm)

  • The head moves in one direction until reaching the disk end, then reverses, servicing all requests in its path along the way
  • Provides more uniform wait times compared to SSTF, since requests aren't indefinitely skipped
  • Has an edge bias problem: requests near the position the head just passed must wait for a full round-trip. Requests at the edges of the disk experience longer maximum waits than those in the middle.

C-SCAN (Circular SCAN)

  • The head only services requests in one direction. After reaching the end of the disk, it jumps back to the beginning without servicing anything on the return trip, then sweeps forward again.
  • This treats the disk as if it were circular, which produces more uniform wait times than SCAN. No cylinder position is systematically disadvantaged.
  • The tradeoff is the "dead" return trip, where no requests are served, slightly reducing raw throughput compared to SCAN.

Compare: SCAN vs. C-SCAN both use directional sweeping, but SCAN services requests in both directions while C-SCAN only services in one. C-SCAN provides more predictable wait times at the cost of the wasted return sweep. If asked to optimize for fairness among all cylinder positions, C-SCAN is the stronger choice.


Optimized Elevator Variants

These algorithms refine the elevator approach by eliminating unnecessary head movement to disk boundaries when no requests exist there.

LOOK Algorithm

  • The head reverses at the last pending request in each direction rather than traveling all the way to the physical disk end
  • This reduces wasted seek time compared to SCAN. The name comes from the idea that the head "looks" ahead and reverses if there are no more requests in that direction.
  • Maintains SCAN's fairness properties with better average seek times. Many real systems use LOOK as a practical default.

C-LOOK Algorithm

  • Combines C-SCAN's unidirectional approach with LOOK's efficiency. After servicing the last request in the current direction, the head jumps back to the first pending request (not the physical start of the disk) and sweeps forward again.
  • This eliminates two sources of wasted movement: unnecessary travel to disk boundaries on both the forward sweep and the return jump.
  • Often the best general-purpose choice in high-throughput environments where both efficiency and fairness matter.

Compare: LOOK vs. C-LOOK mirrors the SCAN vs. C-SCAN relationship. LOOK services bidirectionally; C-LOOK uses unidirectional sweeps with jumps. C-LOOK typically wins on wait-time uniformity, while LOOK may have a slight edge on raw throughput in certain workloads.


Quick Reference Table

ConceptBest Examples
Simple/Fair schedulingFCFS
Greedy optimizationSSTF
Starvation riskSSTF, SCAN (at edges)
Elevator-style movementSCAN, C-SCAN, LOOK, C-LOOK
Uniform wait timesC-SCAN, C-LOOK
Efficiency optimizationLOOK, C-LOOK
Convoy effectFCFS
Circular disk treatmentC-SCAN, C-LOOK

Self-Check Questions

  1. Which two algorithms share the "elevator" movement pattern but differ in how they handle the return sweep? What's the practical impact of this difference?

  2. If a system experiences starvation where requests at cylinder 0 rarely get serviced, which algorithm is likely in use, and what would you recommend instead?

  3. Compare FCFS and SSTF: under what workload conditions would FCFS actually outperform SSTF?

  4. A system administrator notices the disk head frequently travels to the physical end of the disk even when no requests exist there. Which algorithm should replace the current one, and why?

  5. You need to design a scheduling approach that balances throughput and fairness for a busy file server. Which algorithm would you choose, and what tradeoffs would you acknowledge?