Disk Arm Scheduling Simulator (28 Days of Hacking: Day 2)

I decided to write a simple simulator for disk arm scheduling. It supports first come first serve, shortest distance first and elevator. First come first serve may be a fair scheduling algorithm since it handles all requests equally; however, FCFC is extremely bad. Shortest distance first scheduling seems like a great idea, however as the buffer starts running low, the arm will statistically end up jumping around a lot more. Furthermore, there is no minimum bound on the time it takes for a request to be completed. Elevator scheduling works just like it sounds. The arm moves in one direction, processing the next closest request in the current direction. When it reaches the end (or has no more requests in that direction), it changes direction. This may not perform as well as shortest distance first initially, but over time it will do much better. To test, I ran over 2 sequences of 20 positions, using the initial position of 50 for the first sequence.

First Come, First Serve:

Shortest Distance First:


In the end, the FCFS algorithm needed 1200 steps for the random sequence. SDF and Elevator came in at 287 and 217 respectively.