FCFS, SSTF and SCAN
FCFS, SSTF and SCAN
Recorded by Dr. Krithika L.B. Slot m5-disk-sched-1
Ordering the disk queue to minimise arm movement — six algorithms on the same request queue, each with a step-by-step head-movement chart.
By the end of this session you should be able to:
Requests for disk I/O arrive from many processes. When the disk is busy they wait in a queue, and the OS can choose the order in which to serve them. The goal is to minimise total head movement (seek distance), and so improve bandwidth and access time, without starving any request.
Cylinders 0–199. Request queue: 98, 183, 37, 122, 14, 124, 65, 67. The head is at 53. Every simulator below starts with this data — press Step to watch the arm move, or change the inputs.
Serve requests in arrival order. Fair, but the arm swings wildly: 53 → 98 → 183 → 37 → 122 → 14 → 124 → 65 → 67 = 640 cylinders.
Serve the pending request closest to the current head position: 53 → 65 → 67 → 37 → 14 → 98 → 122 → 124 → 183 = 236 cylinders. Much better, but like SJF it can starve requests far from the head if new nearby requests keep arriving — and it is not optimal (53 → 37 → 14 → 65 … gives 208).
The arm starts at one end and moves toward the other, serving requests as it reaches each cylinder, then reverses — like a lift.
Requests just behind the head wait almost two full sweeps; those in the middle are served more often than those at the ends.
Serve requests in one direction only. When the arm reaches the end it returns immediately to the beginning without serving requests on the way back, treating the cylinders as a circular list. This gives a more uniform wait time. Moving up: 53 → 65 → 67 → 98 → 122 → 124 → 183 → 199 → 0 → 14 → 37 = 382 including the 199-cylinder return (183 if the return is not counted).
SCAN and C-SCAN travel all the way to the end of the disk even when there are no requests there. LOOK and C-LOOK go only as far as the last request in each direction, then reverse (LOOK) or jump back to the lowest pending request (C-LOOK).
Textbooks differ on whether the return sweep of C-SCAN/C-LOOK counts as head movement, and on the initial direction. In exams, state your assumptions (direction, and whether the return is counted). The simulators and the lab programs count it.
| Algorithm | Total (example, moving up) | Starvation? | Notes |
|---|---|---|---|
| FCFS | 640 | No | Fair, slow |
| SSTF | 236 | Yes | Good throughput, not optimal |
| SCAN | 331 (236 moving down) | No | Elevator; edges served less often |
| C-SCAN | 382 incl. return | No | Uniform waiting time |
| LOOK | 299 | No | SCAN without going to the end |
| C-LOOK | 322 incl. jump | No | C-SCAN without going to the end |
SSTF is common and natural; SCAN/C-SCAN (or LOOK/C-LOOK) perform better under heavy load because they cannot starve. Performance also depends on the file-allocation method (contiguous files cause less movement) and on where directories and inodes are placed. Modern drives schedule internally, and for SSDs the OS typically uses simple FCFS-like (noop/mq-deadline) schedulers.
FCFS, SSTF and SCAN
Recorded by Dr. Krithika L.B. Slot m5-disk-sched-1
C-SCAN, LOOK and C-LOOK
Recorded by Dr. Krithika L.B. Slot m5-disk-sched-2
Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.
Answer each question in your own words first, then reveal the model answer.
Revealed 0FCFS: 40 + 85 + 60 + 35 = 220. SSTF: 50 → 35 → 10 → 70 → 95 = 15 + 25 + 60 + 25 = 125.
SCAN.
SSTF (and FCFS cannot; SCAN/C-SCAN/LOOK/C-LOOK cannot).
LOOK reverses at the last request in the current direction instead of travelling to the end of the disk.
SSDs have no seek time or rotational latency; access time hardly depends on the address.
We have managed every resource — CPU, memory, files, devices. Now we must protect them, starting with the threats an OS faces and the cryptography used to defend against them.
Continue to 5.3 — Program and network threats, cryptography →