THINK FIRST·CODE LATER

← All labs

Disk-scheduling simulator

Problem

Input: algorithm (FCFS, SSTF, SCAN, CSCAN, LOOK, CLOOK), the last cylinder max (cylinders 0 … max), the initial head position, the initial direction (up or down), then the request queue.

Rules:

  • SSTF: nearest request next; ties → the lower cylinder.
  • SCAN: serve requests in the current direction, go to the end (0 or max) only if requests remain on the other side, then reverse.
  • LOOK: like SCAN, but reverse at the last request.
  • CSCAN: serve in the current direction, go to the end, jump to the other end (the jump counts as head movement), and continue in the same direction.
  • CLOOK: like CSCAN, but go only to the last request and jump directly to the farthest request on the other side (the jump counts).
  • A request at the head's current position counts as being on the up side.

Print Order: 53 -> 65 -> … (starting at the head) and SSTF total head movement: 236 cylinders.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.