Shortest Seek Time First (SSTF) is a disk scheduling algorithm that selects the request with the minimum seek time from the current head position. This strategy minimizes head movement, improving performance compared to FCFS, but can lead to starvation of some requests.
How SSTF Works
In SSTF disk scheduling, the disk controller always services the pending request closest to the current head position, regardless of direction. This approach aims to minimize the total head movement by always choosing the "nearest neighbor" request.
The algorithm follows these steps:
- Calculate the absolute difference between the current head position and each request in the queue
- Service the request with the smallest seek distance from the current position
- Update the current head position and repeat the process for remaining requests
- Continue until all requests are serviced
Example Calculation
Let's say we have a disk with 200 cylinders (0-199), and the head is currently at position 50. The request queue is:
| Request Sequence | 95 | 180 | 34 | 119 | 11 | 123 | 62 |
|---|
The SSTF will reorder these requests based on proximity to the current head position:
| Order | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th |
|---|---|---|---|---|---|---|---|
| Position | 50 | 62 | 34 | 11 | 95 | 119 | 123 |
| Next Request | 62 | 34 | 11 | 95 | 119 | 123 | 180 |
| Movement | 12 | 28 | 23 | 84 | 24 | 4 | 57 |
Total head movement = 12 + 28 + 23 + 84 + 24 + 4 + 57 = 232 cylinders
Advantages
- Better performance than FCFS with lower average seek time
- Increased throughput due to reduced head movement
- Relatively simple to implement
- More efficient use of disk I/O bandwidth
Disadvantages
- Potential for starvation of some requests if new requests keep arriving closer to the head position
- Not the most optimal algorithm for overall disk scheduling
- No consideration for the direction of head movement (unlike SCAN and its variants)
- Higher computational overhead than FCFS, as distances must be calculated for each decision