Disk Scheduler Assignment

Last modified: "June 26, by mevett"
Remember that the head starts over track 0.

This assignment is somewhat similar to the CPU scheduling assignment, excepting that it doesn't use threads, so it should be much easier to complete.

Write a program to simulate the application of different disk scheduling algorithms to a common input reference string. The algorithms to be simulated are SSTF, FCFS, and LOOK.

Program Input and Output

Your program should take its input from a file, "input.txt". The first line of the file will contain a single integer, equal to the number of tracks on the simulated disk. You should assume the head starts over track 0. The remainder of the file will consist of a sequence of entries separated by linefeeds. Each entry represents the submission of a track request to the scheduler. The entries are of the form:

s t

Where s and t are both positive integers and s is the number of milliseconds elapsed since the submission of the previous request and t is the track number requested. Keep in mind that requests will be received as other requests are being serviced.

Your program should generate a table that, for each type of scheduler, prints the order in which each algorithm services the requests, the time of each service, which track is being served, and the total elapsed simulated time to service all requests. You should assume that the simulated disk head starts over track 0 at the start of the simulation. Rather than measuring time directly, you should merely assume that it takes 1 millisecond to traverse each track. Thus to move the head from track 30 to track 67 would require 37 milliseconds of simulated time.

Here is some sample input.

Here is sample output. My output is a bit verbose. All you really need is the sequence of track services (such as the lines marked with ">>>>" in my output) along with a table that summarizes the total service times for each method.

Hints

You may want to use Java's built-in StreamTokenizer class to read the input file, but there are many other ways.   Check out the Java documentation.

Note that the time of each event is not explicitly stated, but rather is equal to the sum of the "start time-deltas" that precede it in the input file. 

Dealing with simultaneity

Once the "disk head" has started moving toward servicing a request, R , the system should ignore any new request submissions until R is serviced. (Those incoming requests will be queued, but they will not be serviced as the head is on the way to R.)

Reading from files in Java

Here is a brief explanation into reading character files in Java.