# Disk scheduling: FCFS, SSTF, SCAN and C-SCAN

> Explain disk scheduling algorithms. For requests 98, 183, 37, 122, 14, 124, 65, 67 with the head at 53 on a disk with cylinders 0 to 199, compute the...

Canonical: https://www.internhack.in/learn/interview/operating-systems-interview/os-disk-scheduling-algorithms
Last updated: 2026-11-28

Difficulty: Beginner

## Question

Explain disk scheduling algorithms. For requests 98, 183, 37, 122, 14, 124, 65, 67 with the head at 53 on a disk with cylinders 0 to 199, compute the total head movement for FCFS, SSTF and SCAN.

## Answer

On a traditional hard disk, reading data involves three delays: seek time (moving the read/write head to the right cylinder), rotational latency (waiting for the sector to rotate under the head) and transfer time. Seek time dominates, so the OS reorders pending requests to minimize total head movement. This is disk scheduling. Think of an elevator: if it went to floors in the order people pressed buttons, it would zigzag wastefully, so real elevators sweep in one direction, serving requests on the way. Disk scheduling applies the same idea.

Let's define our data. The disk has cylinders 0 to 199, the head starts at 53, and the request queue is 98, 183, 37, 122, 14, 124, 65, 67. We measure total head movement in cylinders.

FCFS serves requests in arrival order. Movement: 53 to 98 is 45, 98 to 183 is 85, 183 to 37 is 146, 37 to 122 is 85, 122 to 14 is 108, 14 to 124 is 110, 124 to 65 is 59, 65 to 67 is 2. The total is 45 + 85 + 146 + 85 + 108 + 110 + 59 + 2 = 640 cylinders. It is fair but wild swings waste effort.

SSTF (Shortest Seek Time First) always serves the request closest to the current head position. From 53 the nearest is 65 (12), then 67 (2), then 37 (30), then 14 (23), then 98 (84), then 122 (24), then 124 (2), then 183 (59). The total is 12 + 2 + 30 + 23 + 84 + 24 + 2 + 59 = 236 cylinders. It is much better than FCFS but can starve far-away requests, if new close requests keep arriving, much like SJF.

SCAN, the elevator algorithm, moves the head in one direction to the end of the disk, serving requests along the way, and then reverses. Suppose the head is at 53 moving towards 0. It serves 37 and 14 (movement 16 then 23), continues to cylinder 0 (14 more), then reverses and travels up serving 65, 67, 98, 122, 124 and 183. Total movement is 53 to 0 (53) plus 0 to 183 (183) = 236 cylinders. It gives a fairly uniform wait time and avoids starvation. Its weakness is that cylinders just visited are revisited only after the head goes to the far end and back, so the wait is uneven for the edges.

C-SCAN (Circular SCAN) improves fairness by serving requests in one direction only. On reaching the end, the head jumps back to the start without serving anything on the return trip, and continues in the same direction. Going upward from 53: serve 65 through 183, go to 199, jump to 0, then serve 14 and 37. The movement is 146 up to 199, plus the return jump of 199 if counted, plus 37 from 0 to 37, so 382 in total when the jump is counted. Waiting times are more uniform than SCAN.

LOOK and C-LOOK are practical variants that go only as far as the last request in each direction instead of to the physical end of the disk. LOOK toward 0 first would give 53 to 14 (39) then 14 to 183 (169) = 208 cylinders, better than SCAN's 236 here.

Choosing an algorithm depends on load. Under light load, FCFS is fine. Under heavy load, SCAN or C-SCAN variants perform best and avoid starvation. Finally, mention that modern SSDs have no moving head, so seek-optimizing schedulers matter little; Linux uses simple schedulers like noop, mq-deadline or BFQ for them.

## Code examples

### Head movement calculations

```
Queue: 98 183 37 122 14 124 65 67   Head = 53   Cylinders 0..199

FCFS : 53>98>183>37>122>14>124>65>67
       45+85+146+85+108+110+59+2 = 640

SSTF : 53>65>67>37>14>98>122>124>183
       12+2+30+23+84+24+2+59 = 236

SCAN (toward 0 first): 53>37>14>0>65>67>98>122>124>183
       16+23+14+65+2+31+24+2+59 = 236   (= 53 + 183)

C-SCAN (upward, jump counted): 53>65>67>98>122>124>183>199>0>14>37
       146 + 199 + 37 = 382

LOOK (toward 0 first): 53>37>14>65>67>98>122>124>183
       39 + 169 = 208
```

Total head movement is the sum of absolute differences between consecutive cylinder positions. SCAN and SSTF tie at 236 for this input by coincidence.

## Key points

- Seek time dominates disk access; scheduling minimizes head movement.
- FCFS is fair but slow; SSTF is efficient but can starve.
- SCAN is the elevator algorithm; C-SCAN gives more uniform waiting.
- LOOK and C-LOOK do not travel to the disk ends unnecessarily.
- SSDs have no seek time, so classical disk scheduling matters far less.

## Common follow-up questions

- Why can SSTF starve requests?
- What is the difference between SCAN and LOOK?
- How does rotational latency affect scheduling?
- Do SSDs need disk scheduling?

## Interview tips

- Write the movement as a sum of differences so the arithmetic can be checked.
- Say the direction of head movement for SCAN before computing.
- Mention that the C-SCAN return jump may or may not be counted; state your assumption.

## Concepts covered

disk scheduling, seek time, SCAN, SSTF, C-SCAN

Previous: [File systems, inodes and directory structure](https://www.internhack.in/learn/interview/operating-systems-interview/os-file-systems-and-inodes) · [All of Operating Systems](https://www.internhack.in/learn/interview/operating-systems-interview)

## More Operating Systems questions

- [Explain kernel mode vs user mode and how system calls work](https://www.internhack.in/learn/interview/operating-systems-interview/os-kernel-mode-user-mode-system-calls)
- [Monolithic kernel vs microkernel: differences and trade-offs](https://www.internhack.in/learn/interview/operating-systems-interview/os-monolithic-vs-microkernel)
- [Program vs process: what is the difference?](https://www.internhack.in/learn/interview/operating-systems-interview/os-process-vs-program)
- [Process states, state transitions and the Process Control Block](https://www.internhack.in/learn/interview/operating-systems-interview/os-process-states-and-pcb)
- [Process vs thread: key differences](https://www.internhack.in/learn/interview/operating-systems-interview/os-process-vs-thread)
- [User-level threads vs kernel-level threads and threading models](https://www.internhack.in/learn/interview/operating-systems-interview/os-user-level-vs-kernel-level-threads)

## Related

- [Learn](https://www.internhack.in/learn)
- [Interview Prep](https://www.internhack.in/learn/interview)
- [Operating Systems](https://www.internhack.in/learn/interview/operating-systems-interview)
