The disk and its queue
A hard disk keeps data on rings called tracks. To read one, an arm must move the head to that track first: a seek. Seeks are slow, about 4 to 9 ms on average, so less arm travel means faster reads.
Many programs ask for data at once, so the operating system keeps a queue of requests, each naming a track. Eight wait here: 98, 183, 37, 122, 14, 124, 65, 67. The head is on track 53. Which one should go next?
Three orders
FCFS serves requests in arrival order. That is fair, but the head zigzags across the whole disk: 53 to 98, out to 183, back to 37. In total it moves 640 tracks.
SSTF always serves the request nearest the head. From 53 it goes to 65 and 67, then down to 14, then up to 183. The head moves only 236 tracks instead of 640.
SSTF has a flaw. Say the head is on 65 and 183 is waiting. If new requests keep arriving near the head, each one is nearer, so it jumps ahead. Track 183 can wait forever: it starves.
SCAN sweeps like a lift: one way to the edge, serving everything it passes, then back. Down from 53: 37, 14, the edge, then up to 183. 236 tracks, and nobody waits forever.
Which is best?
FCFS moved 640 tracks, SSTF 236, SCAN 236. SSTF and SCAN both cut the travel by more than 60 percent. Of those two fast ones, only SCAN also promises that every request gets served: no starvation.
Modern disks know their exact head position, so the OS hands them several requests and the drive orders them itself. Linux still offers schedulers such as mq-deadline. Solid-state drives (SSDs) have no moving head, so there is often less to gain.
What happens
;; step 1/8 · disk time for one read = seek + rotation + transfer seek move the arm to the right track rotation wait for the data to spin under the head transfer read the bytes average seek (OSTEP, Fig. 37.5): Cheetah 15K.5 15,000 RPM 4 ms Barracuda 7,200 RPM 9 ms Below, the tracks are laid out in a straight line: track 0 at the outer edge, track 199 at the inner edge.
The figure lays the tracks out in a straight line, from track 0 at the outer edge to track 199 at the inner edge, and pretends each request names a track. A real OS sees numbered blocks instead, and nearby block numbers usually sit on nearby tracks, so it orders requests by block number (nearest-block-first). Only seek distance is counted here. A real read also waits for the data to spin under the head; a drive that knows both can use shortest positioning time first (SPTF), which modern drives run internally.