CPSC380 Programming Assignment 7 solution




5/5 - (5 votes)


The objective of this assignment consists of writing a C/C++ program that simulates the various disk-scheduling algorithms

Assignment: Implementing a disk scheduler

Your program will implement the following disk-scheduling algorithms:

  1. FCFS
  2. SSTF
  3. SCAN
  4. C-SCAN
  5. LOOK
  6. C-LOOK

Your program will service a disk with 5,000 cylinders numbered 0 to 4,999. The program will read a file that contains a series of 1000 cylinder requests and services them according to each of the algorithms listed above. The program will be passed the initial position of the disk head (as a parameter on the command line) as well as the file name containing the random cylinder requests. The program is to report the total amount of head movement required by each algorithm as a summary at the end of the program.


Run the Program

The file cylinders.txt (provided on Blackboard), contains 1000 integer values representing a specific cylinder request which your program will open to calculate the total head movement for each algorithm.

Your program should run as follows:


./diskScheduler <initial cylinder position>  <cylinder request file>


After completion, your program is to report (output as well) the following statistics:


Total Head Movement for FCFS               : xxxxxxxx

Total Head Movement for SSTF               : xxxxxxxx

Total Head Movement for SCAN             : xxxxxxxx

Total Head Movement for C-SCAN         : xxxxxxxx

Total Head Movement for LOOK             : xxxxxxxx

Total Head Movement for C-LOOK         : xxxxxxxx




Error Handling

Perform the necessary error checking to ensure the correct number of command-line parameters as well as checking for the address file.


The program will be graded on the basic functionality, error handling and how well the implementation description was followed. Be sure to name your program diskScheduler (no extra characters, capitals) Note that documentation and style are worth 10% of the assignment’s grade!


The program source code and program output should be posted to Blackboard.