CSC 442 Homework 3
Write a program that can simulate the following CPU scheduling algorithms:
- RR (new processes are added at the beginning of the ready queue, the quantum is one time unit)
- Priority based
- SJF non-preemptive
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.
1. The program must:
- Ask the user for the name of a file containing its input data. The file will have the following format:
- Number of processes.
- 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.
- 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):
10 3 0
1 1 0
2 3 0
1 4 0
5 2 0
- Calculate the Gantt diagram. The diagram will be displayed as follows:
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).
- 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.
- A print-out of your program.
- A written description of the program and its behavior.
- 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.
- A sample output illustrating what the program produces.