Tech

Disk Scheduling Algorithms: A Complete Guide

disk scheduling algorithms determine the order in which read and write requests to a hard disk are processed. When multiple processes request disk access at the same time, the operating system uses a scheduling algorithm to decide which request gets handled first, helping minimize seek time and improve overall performance.

The most commonly used algorithms are FCFS (First Come First Served), SSTF (Shortest Seek Time First), SCAN, C-SCAN, LOOK, and C-LOOK. Each has different trade-offs between efficiency, fairness, and implementation complexity. In modern operating systems, LOOK and C-LOOK are the most widely used because they balance performance with fairness.

Why Disk Scheduling Matters

Hard disk drives (HDDs) have a physical read/write head that moves across rotating platters. Moving this head – called seeking – takes time. The further the head must travel between requests, the more time is wasted.

Disk scheduling reduces this wasted time by reordering requests intelligently. Even though SSDs don’t have mechanical heads, disk scheduling concepts still apply in operating systems design and are a core topic in computer science education.

Key metric: total head movement (measured in cylinders) is used to compare algorithm efficiency.

All Disk Scheduling Algorithms Compared

Algorithm How It Works Pros Cons Best Use
FCFS Serves requests in arrival order Simple, fair, no starvation High seek time, inefficient Low load
SSTF Serves nearest track first Low avg seek time Starvation of far requests General
SCAN Sweeps back and forth like elevator No starvation, predictable Uneven wait at edges Heavy load
C-SCAN Sweeps one way, resets to start Uniform wait times More head movement Fairness needed
LOOK Like SCAN but reverses at last request Efficient, less movement Slightly complex Most HDDs
C-LOOK Like C-SCAN but reverses at last request Best of C-SCAN + LOOK Complex to implement Servers

Worked Example: Request Queue

Assume the disk head starts at cylinder 50. The request queue is: 98, 183, 37, 122, 14, 124, 65, 67. Here’s how different algorithms handle it:

Algorithm Seek Order Total Head Movement
FCFS 50→98→183→37→122→14→124→65→67 640 cylinders
SSTF 50→65→67→37→14→98→122→124→183 236 cylinders
SCAN 50→65→67→98→122→124→183→37→14 208 cylinders
LOOK 50→65→67→98→122→124→183→37→14 190 cylinders (reverses at 183)

Algorithm Deep Dives

FCFS (First Come First Served)

The simplest approach – handle requests in the order they arrive. No request is skipped, so starvation is impossible. But it’s highly inefficient because the head may zigzag across the disk unnecessarily.

SSTF (Shortest Seek Time First)

Always pick the request closest to the current head position. Much more efficient than FCFS. The downside: requests far from the head may wait indefinitely (starvation), especially under heavy loads.

SCAN (Elevator Algorithm)

The head moves in one direction, serving all requests along the way. When it reaches the end, it reverses. Like an elevator – it only changes direction when it hits the boundary. Prevents starvation but can make requests near the recently-reversed end wait longer.

C-SCAN (Circular SCAN)

Like SCAN, but after reaching the end, the head jumps back to the beginning and sweeps in the same direction again (not in reverse). This gives more uniform wait times across all cylinders.

LOOK and C-LOOK

Improvements over SCAN and C-SCAN respectively. Instead of going all the way to the end of the disk, the head reverses (LOOK) or resets (C-LOOK) at the last actual request. This reduces unnecessary head movement and is the basis for most real-world implementations.

Which Algorithm Is Used in Practice?

  • HDDs: LOOK and C-LOOK are the standard in most operating systems (Linux, Windows) for rotating hard disks.
  • SSDs: Seek time is negligible, so simpler schedulers (like NOOP or deadline scheduler) are preferred for SSDs.
  • Linux I/O Scheduler: Uses BFQ (Budget Fair Queueing) for HDDs and NOOP/none for NVMe SSDs by default.

Summary

Disk scheduling is a classic operating systems problem with real performance implications for HDD-based systems. For exam preparation, focus on SCAN and LOOK – they’re the most commonly tested. For real-world understanding, know that SSDs have changed the landscape, making algorithm choice less critical for storage performance than it once was.

Leave a Reply