The algorithms, one line each
- FCFS serves requests in the order they came. Fair, but the head swings back and forth across the disk.
- SSTF (shortest seek time first) always goes to the closest request next. Little movement, but a request far away can wait forever.
- SCAN, the elevator: the head moves one way serving requests, goes on to the edge of the disk, then turns round.
- C-SCAN is SCAN in one direction only: at the edge it jumps back to the other end and starts again, so waiting times are more even.
- LOOK and C-LOOK are SCAN and C-SCAN that turn round (or jump back) at the last request instead of the edge of the disk.
Formulas
- Total head movement = the sum of every move's distance, |from − to|.
- Average seek length = total head movement ÷ number of requests.
- Seek time = total head movement × the time per cylinder, when the question gives one.
The rules this simulator follows
- SSTF: when two requests are equally close, the one that came first in the queue goes first.
- SCAN and C-SCAN go on to the edge (0 or the last cylinder) only if requests are left on the other side. LOOK and C-LOOK turn at the last request.
- C-SCAN and C-LOOK: the jump back is counted in the total. Some books and exam keys leave it out, so the total without it is shown too.
- For SCAN, C-SCAN, LOOK and C-LOOK the direction matters: look for "moving towards higher cylinders" or "towards 0" in your question.
Exam traps
- "Cylinders 0 to 199" means 200 cylinders, and the last one is 199.
- SCAN runs on to the edge even when the last request is nearer; LOOK doesn't. Mixing them up is the most common lost mark.
- For C-SCAN, read whether the return seek counts before you add it up.
More simulators: CPU scheduling, page replacement and the Banker's algorithm.