The goal of this assignment is to compare the performance of CPU Scheduling algorithms for a given set of processes and a given value of quantum. Basically, you are to write a program to draw Gantt charts and calculate the waiting time and turnaround times for a set of processes under the following CPU scheduling algorithms:
Before starting to execute, your program asks the user to enter the following:
P1 5
P2 3
P3 4
P4 3
P5 6
The input file is interpreted as follows:
The output of your program should include two parts, Gantt charts and Output Statistics, explained as follows. Instead of displaying the output on the screen, the output of your program should be stored in a text file for easy checking of output correctness.
The first part of the output should be two vertical Gantt charts, one for FCFS and the other for RR with the given quantum. Each Gantt chart is represented in two columns as follows. The first column is the time point and the second column is the process ID for the process that was running on CPU at this time point.
Gantt Chart for FCFS:
Time Process Id
0 P1
1 P1
2 P1
3 P1
4 P1
5 P2
6 P2
7 P2
Gantt Char for RR (quantum = 2)
Time Process Id
0 P1
1 P1
2 P2
3 P2
4 P3
5 P3
6 P4
7 P4
8 P5
9 P5
In this part you required to display the waiting time and the turnaround time for all processes in the work load. Waiting time is defined as the time that the process spent in the ready queue. However, the turnaround time is the overall time spent by the process in the system (i.e., finish time – arrival time).
Waiting Times
ID FCFS RR
P1 0 14
P2 5 10
P3 8 11
P4 12 13
P5 15 15
Turnaround Times
ID FCFS RR
P1 5 19
P2 8 13
P3 12 15
P4 15 16
P5 21 21
You can use either Java or C/C++ as a programming language to implement your algorithms. Just make sure that you turn in detailed instructions on how to compile and run your code.