Operating System - Shortest Seek Time First (SSTF) Disk Scheduling Algorithm

Definition:

SSTF (Shortest Seek Time First) is a disk scheduling algorithm that selects the I/O request which is closest to the current head position, i.e., the request that will result in the minimum seek time.

Key Idea:

Always choose the next request that is nearest to the current head position.

This reduces average seek time compared to FCFS (First-Come, First-Served), but can lead to starvation of distant requests.

How SSTF Works:

  1. Start at the initial head position.

  2. From the list of pending requests, pick the one closest to the current head.

  3. Move the head to that position.

  4. Repeat until all requests are serviced.

Example:

  • Initial Head Position: 53

  • Disk Requests: 98, 183, 37, 122, 14, 124, 65, 67

Step-by-Step Execution:

  1. Start at 53
    Closest = 65 (|53-65| = 12)
    → Move to 65

  2. At 65
    Closest = 67 (|65-67| = 2)
    → Move to 67

  3. At 67
    Closest = 37 (|67-37| = 30)
    → Move to 37

  4. At 37
    Closest = 14 (|37-14| = 23)
    → Move to 14

  5. At 14
    Closest = 98 (|14-98| = 84)
    → Move to 98

  6. At 98
    Closest = 122 (|98-122| = 24)
    → Move to 122

  7. At 122
    Closest = 124 (|122-124| = 2)
    → Move to 124

  8. At 124
    Closest = 183
    → Move to 183

SSTF Order of Service:

53 → 65 → 67 → 37 → 14 → 98 → 122 → 124 → 183

Head Movements:

Move Distance
53 → 65 12
65 → 67 2
67 → 37 30
37 → 14 23
14 → 98 84
98 → 122 24
122 → 124 2
124 → 183 59
Total 236

 

Program for SSTF Disk Scheduling Algorithm - GeeksforGeeks

Advantages:

  • Better performance than FCFS.

  • Minimizes average seek time.

Disadvantages:

  • Can cause starvation for distant requests.

  • Not optimal in all cases.