---
title: "Short note: SSTF algorithm with example"
subject: "Operating System"
chapter: 6
key: "semester_6/operating_system:sstf-algorithm-note"
source: https://www.bctengineer.com/q/semester_6/operating_system/sstf-algorithm-note
site: BCT Engineering
---

# Short note: SSTF algorithm with example

Operating System · Chapter 6: I/O Management and Disk Scheduling

- Asked in: 2072 Magh, 4 marks
- Video: [L-6.5: SSTF in Disk scheduling with Example | Operating System](https://www.youtube.com/watch?v=P_dA8VGJjA8) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/sstf-algorithm-note
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-6

## Question

Write a short note on Shortest Seek Time First algorithm with example.

## Short answer

SSTF always serves the pending request nearest the current head position, repeating until the queue is empty. For head at 53 and queue 98,183,37,122,14,124,65,67, the order is 53,65,67,37,14,98,122,124,183 with total movement 236 cylinders. It reduces seek time but can starve distant requests.

## Answer

**Shortest Seek Time First (SSTF)** is a disk scheduling algorithm that always serves the pending request closest to the current head position, i.e. the one needing the smallest seek.

#### Working
1. Note the current head position.
2. From the request queue, pick the cylinder with the minimum |request − head|.
3. Move the head there, serve it, remove it from the queue.
4. Repeat until the queue is empty. (Ties are broken arbitrarily, or by direction.)

#### Example
Head at 53; queue = 98, 183, 37, 122, 14, 124, 65, 67 (cylinders 0–199).

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

| 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** |

FCFS needs 640 cylinders for the same queue, so SSTF is much better.

#### Advantages and disadvantages
- Lower average seek time and higher throughput than FCFS.
- Not optimal in every case, because it is a greedy choice.
- **Starvation:** requests far from the head may wait indefinitely if new requests keep arriving near the head.
- Favours the middle cylinders; response time varies widely.

**Answer: total head movement = 236 cylinders.**

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does SSTF do at each step?
   A. Serves the oldest request
   B. Serves the pending request with the smallest |request - head|
   C. Serves requests only in the direction of motion
   D. Serves the request with the highest cylinder
   Answer: B. SSTF is greedy: it always picks the closest cylinder to the current head position. (Key point: SSTF rule)

2. Head at 53, queue 98, 183, 37, 122, 14, 124, 65, 67. What is the SSTF total?
   A. 236
   B. 640
   C. 208
   D. 331
   Answer: A. Order 65, 67, 37, 14, 98, 122, 124, 183 gives 12+2+30+23+84+24+2+59 = 236. (Key point: SSTF example total)

3. Why can SSTF cause starvation?
   A. It reverses direction too often
   B. It ignores the queue order of near requests
   C. New requests keep arriving near the head, so far requests may wait indefinitely
   D. It always serves the farthest request first
   Answer: C. A greedy nearest-first choice can keep postponing distant requests. (Key point: Starvation)

## Related in Operating System

- [Interleaving; SSTF, SCAN, C-SCAN order](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Ainterleaving-winchester-disk-scheduling) — Operating System, chapter 6
- [Disk scheduling with 100 cylinders](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adisk-100-cyl-fcfs-sstf-look-cscan-scan) — Operating System, chapter 6, asked 2×
- [Preemptive vs non-preemptive; real-time scheduling](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apreemptive-nonpreemptive-realtime) — Operating System, chapter 2
- [Rate Monotonic real-time schedule](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Arate-monotonic-schedule) — Operating System, chapter 2
- [Preemptive priority and SRTF Gantt](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apreemptive-priority-srtf-gantt) — Operating System, chapter 2

## Related in other subjects

- [Dijkstra's shortest path algorithm](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adijkstra-algorithm-example) — Data Structure and Algorithm, chapter 10, asked 2×
- [Dijkstra shortest path (2071 Bhadra)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2071-bhadra) — Discrete Structure, chapter 4, asked 4×
- [Dijkstra shortest path (2070 Magh)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2070-magh) — Discrete Structure, chapter 4, asked 4×
- [Dijkstra shortest path (2069 Bhadra)](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Adijkstra-2069-bhadra) — Discrete Structure, chapter 4, asked 4×
