Practice · Core CS simulator

Disk scheduling simulator

Type the request queue, where the head starts and the disk's size. See the order the head serves them, its path, and the total head movement, for every algorithm.

Total head movement: 236 cylinders · average 29.50 per request

Order served: 53 → 65 → 67 → 37 → 14 → 98 → 122 → 124 → 183

Every move explained
  1. 53 → 65: the closest request (12 cylinders)
  2. 65 → 67: the closest request (2 cylinders)
  3. 67 → 37: the closest request (30 cylinders)
  4. 37 → 14: the closest request (23 cylinders)
  5. 14 → 98: the closest request (84 cylinders)
  6. 98 → 122: the closest request (24 cylinders)
  7. 122 → 124: the closest request (2 cylinders)
  8. 124 → 183: the closest request (59 cylinders)

Every algorithm, same requests

SCAN, C-SCAN, LOOK and C-LOOK start up. The least movement is marked; C-SCAN and C-LOOK count the jump back.
AlgorithmTotalAverage
64080
23629.50
33141.38
38247.75
29937.38
32240.25

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.