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:
-
Start at the initial head position.
-
From the list of pending requests, pick the one closest to the current head.
-
Move the head to that position.
-
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:
-
Start at 53
Closest = 65 (|53-65| = 12)
→ Move to 65 -
At 65
Closest = 67 (|65-67| = 2)
→ Move to 67 -
At 67
Closest = 37 (|67-37| = 30)
→ Move to 37 -
At 37
Closest = 14 (|37-14| = 23)
→ Move to 14 -
At 14
Closest = 98 (|14-98| = 84)
→ Move to 98 -
At 98
Closest = 122 (|98-122| = 24)
→ Move to 122 -
At 122
Closest = 124 (|122-124| = 2)
→ Move to 124 -
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 |
Advantages:
-
Better performance than FCFS.
-
Minimizes average seek time.
Disadvantages:
-
Can cause starvation for distant requests.
-
Not optimal in all cases.