CSC 442 Homework 3

Write a program that can simulate the following CPU scheduling algorithms:

    1. FCFS
    2. RR (new processes are added at the beginning of the ready queue, the quantum is one time unit)
    3. Priority based
    4. SJF non-preemptive
    5. SRTF

The program can be written in either C or Pascal. Although the platform for development can be one of your choice, the program must be portable (i.e. platform independent) and its final version must run correctly on the server of the computer science department where the grading will be performed.

Specifications:

1. The program must:

    1. Ask the user for the name of a file containing its input data. The file will have the following format:
      1. Number of processes.
      2. A number of lines containing the data for each process. Each process will have one line which will contain in the following order: the burst time, the priority (the lower the number the higher the priority) and the arrival time.
      3. The algorithm(s) required. The algorithm will be specified as one of: FCFS, RR, Priority, SJF, SRTF

      This is an example of an input file (corresponding to exercise 5.3 page 150):

      5

      10 3 0

      1 1 0

      2 3 0

      1 4 0

      5 2 0

      FCFS

      SJF

      Priority

      RR

    2. Calculate the Gantt diagram. The diagram will be displayed as follows:
    3. 0 -p1- 2 -p2- 5 -p3- 7

      The example shows P1 running for 2 time units (from 0 to 2) then P2 running for 3 time units (from 2 to 5) then P3 running for 2 units (from 5 to 7).

    4. Calculate the waiting time of each process and the average waiting time for the given algorithms.

Note that the only interaction with the user is at the very beginning when the programs should ask the name of the file containing the input data.

 

Submit:

  1. A print-out of your program.
  2. A written description of the program and its behavior.
  3. The source code of the program. The source code should be contained in a folder (directory) called "homework3" in your home directory. The permissions of this folder and all the files included should be such that I can open the files, compile them and run the program.
  4. A sample output illustrating what the program produces.