Disk scheduling simulator
A hard disk serves a queue of requests by moving its head across the cylinders, and the order it picks decides how far the head travels. Enter the queue, head position and direction from your exercise to get the service order, the head-movement chart and the total seek distance for each algorithm.
Move 8: 123 → 180, 57 cylinders. 180 is the closest pending request (57 cylinders away).
- Service order
- 62, 64, 34, 11, 95, 119, 123, 180
- Total head movement
- 236
- Average per request
- 29.5
| Algorithm | Total |
|---|---|
| SSTF | 236 |
| LOOK | 299 |
| C-LOOK | 322 |
| SCAN | 337 |
| C-SCAN | 382 |
| FCFS | 644 |
How to use the simulator
Type the request queue from your exercise in arrival order, the head's starting cylinder and the number of cylinders (a disk with cylinders 0 to 199 has 200), choose the direction the head is moving, and pick an algorithm. The chart shows the head's path from top to bottom, with the distance of every move; the panel on the right gives the service order, the total and the totals for all six algorithms at once.
- If your exercise says the head "was previously at" a cylinder, the direction is from that cylinder towards the current one.
- "Copy answer" gives the moves as a table you can paste; "Copy link" reopens this exact exercise.
What is disk scheduling?
On a hard disk, reading a block means moving the arm until the head is over the right cylinder (the seek), waiting for the sector to rotate under it, and transferring the data. Seeks take milliseconds, far longer than the transfer, so when several requests are waiting, the order in which the operating system or the drive serves them changes how much time is spent seeking.
Textbook exercises simplify the cost to the number of cylinders the head crosses, the total head movement, and ignore rotation. The question is then which order serves a given queue with the least movement, without leaving any request waiting too long.
The six algorithms
- FCFS (first come, first served) serves requests in arrival order. It is fair but the head zigzags across the disk.
- SSTF (shortest seek time first) always goes to the nearest pending request. It cuts movement sharply but can leave distant requests waiting.
- SCAN, the elevator algorithm, sweeps towards one end serving requests on the way, goes to the last cylinder, then reverses.
- C-SCAN (circular SCAN) sweeps in one direction only: at the end it returns to the other end and sweeps again, so waiting times are more even.
- LOOK and C-LOOK are SCAN and C-SCAN that turn round at the last request instead of the last cylinder.
On this page's default exercise, the head at 50 on 200 cylinders and the queue 95, 180, 34, 119, 11, 123, 62, 64, with the return jump counted:
| Algorithm | Moving up | Moving down | Service order (moving up) |
|---|---|---|---|
| FCFS | 644 | 644 | 95, 180, 34, 119, 11, 123, 62, 64 |
| SSTF | 236 | 236 | 62, 64, 34, 11, 95, 119, 123, 180 |
| SCAN | 337 | 230 | 62, 64, 95, 119, 123, 180, 34, 11 |
| C-SCAN | 382 | 386 | 62, 64, 95, 119, 123, 180, 11, 34 |
| LOOK | 299 | 208 | 62, 64, 95, 119, 123, 180, 34, 11 |
| C-LOOK | 322 | 326 | 62, 64, 95, 119, 123, 180, 11, 34 |
Conventions that change the answer
Answers to the same exercise differ between textbooks and lecture notes, usually because of one of these:
- The C-SCAN and C-LOOK return. Some count the jump back as head movement, some do not. Moving up on the default exercise, C-SCAN is 382 cylinders with it and 183 without; C-LOOK is 322 and 153.
- SCAN going to the end. Strictly, SCAN travels to the last cylinder before reversing; some solutions turn at the last request, which is LOOK.
- The starting direction. SCAN, LOOK and their circular versions depend on it; SSTF only uses it to break ties.
- Ties in SSTF. When two requests are equally close, some keep going in the current direction and some take the lower cylinder.
Seek distance against fairness
A fixed queue hides the real trade-off, which appears when requests keep arriving. In this simulation, requests arrive at random times at uniformly random cylinders of a 200-cylinder disk, the head moves one cylinder per time unit, and a return jump takes as long as the distance. Waiting times in time units, over 300,000 units:
| Algorithm | Mean wait | 99th percentile | Longest wait | Still queued at the end |
|---|---|---|---|---|
| FCFS | 91 | 353 | 708 | 0 |
| SSTF | 73 | 271 | 487 | 0 |
| SCAN | 133 | 339 | 378 | 0 |
| C-SCAN | 210 | 395 | 398 | 0 |
| LOOK | 77 | 255 | 362 | 0 |
| C-LOOK | 82 | 302 | 456 | 0 |
| Algorithm | Mean wait | 99th percentile | Longest wait | Still queued at the end |
|---|---|---|---|---|
| FCFS | 563 | 2440 | 2765 | 2 |
| SSTF | 87 | 343 | 549 | 1 |
| SCAN | 132 | 357 | 396 | 1 |
| C-SCAN | 204 | 394 | 398 | 2 |
| LOOK | 97 | 294 | 367 | 1 |
| C-LOOK | 126 | 379 | 533 | 1 |
| Algorithm | Mean wait | 99th percentile | Longest wait | Still queued at the end |
|---|---|---|---|---|
| FCFS | unbounded | – | – | 10308 |
| SSTF | 121 | 467 | 1071 | 6 |
| SCAN | 133 | 359 | 396 | 9 |
| C-SCAN | 198 | 394 | 398 | 8 |
| LOOK | 124 | 339 | 390 | 5 |
| C-LOOK | 186 | 451 | 577 | 9 |
FCFS spends about a third of the disk's width on every request, so once requests arrive faster than about one every 66 time units its queue grows without limit. SSTF has the lowest mean wait, but of the five algorithms that sweep or seek nearest, its longest waits are the worst: requests at the edges are passed over while nearer ones keep arriving. SCAN and C-SCAN bound the wait by one sweep; C-SCAN's waits are the most even, at the cost of a higher mean here because its return trip is treated as a full seek.
Disk scheduling today
Modern hard disks reorder queued commands themselves, using Native Command Queuing on SATA drives, and they know their own geometry and rotational position, which the operating system does not. Linux's block layer offers the mq-deadline, BFQ and Kyber schedulers, or none, which is the usual choice for SSDs, since flash has no head to move. The textbook algorithms remain the standard way to teach the trade-off between total seek distance and fairness.
Disk scheduling questions and answers
How do you calculate total head movement?
Write down the cylinders the head visits in order, starting from its initial position, and add up the distance between each pair of consecutive positions. For SCAN and C-SCAN that includes the trip to the end of the disk. With the head at 50 moving up and the queue 95, 180, 34, 119, 11, 123, 62, 64 on 200 cylinders, FCFS moves 644 cylinders, SSTF 236, SCAN 337 and LOOK 299.
What is the difference between SCAN and LOOK?
Both sweep in one direction serving requests, then reverse. SCAN always travels to the last cylinder before reversing; LOOK reverses as soon as there are no more requests ahead. LOOK therefore never moves further than SCAN, and most real implementations of the "elevator" algorithm behave like LOOK.
Does the C-SCAN return jump count as head movement?
Textbooks differ. The head does travel back across the disk, so many count it; others treat the return as a fast seek that does not serve requests and leave it out. On this page’s example moving up, C-SCAN totals 382 cylinders with the return counted and 183 without. Use the switch to match your course.
Why can SSTF cause starvation?
SSTF always serves the closest request, so while new requests keep arriving near the head, a request at the far edge can wait indefinitely. In this page’s simulation of requests arriving at random, SSTF’s longest wait was 1071 time units against 396 for SCAN, even though its average was similar.
Which disk scheduling algorithm is best?
No single one. SSTF and LOOK give low average seek times; SCAN and especially C-SCAN give more uniform waiting times, because every request is reached within one sweep. FCFS is fair but wastes the most movement and collapses first under load. On SSDs, which have no seek time, operating systems often do no reordering at all.
Do modern operating systems still use these algorithms?
Not in their textbook form. Hard disks reorder queued commands themselves (Native Command Queuing on SATA drives), and Linux’s multi-queue block layer offers schedulers such as mq-deadline, BFQ and Kyber, or none, which suits SSDs. The textbook algorithms remain the clearest way to see the trade-off between total seek distance and fairness.