Question: I'm trying to implement simulation of CPU Scheduling Round Robin. I have the code below, but it needs to read the input from a txt
I'm trying to implement simulation of CPU Scheduling Round Robin. I have the code below, but it needs to read the input from a txt file and output the results to a different txt file(preferrably in the same directory as the code. Here is the details of how it works, followed by the code.
Input File:
The first line has a space-separated list of scheduling algorithm names to run (any combination of the four names given above). The second line has a single integer representing the number of processes in the file. The rest of the file has one line per process with the following information:
Process number Arrival Time CPU burst time Priority
If multiple processes have the same arrival time, your scheduling algorithm should assume that there are negligibly small differences in arrival times with the processes arriving in the order they appear in the file. For priority scheduling, assume that smaller numbers indicate higher priorities. Non-priority algorithms will simply ignore the priority field.
Output File:
The output file will have the scheduling results for each of the algorithms listed in the input file. There should be one line for each CPU assignment (one line for each vertical line in the Gantt chart). Each line should have two numbers: one indicating the time point and one indicating the process number that got the CPU at that point. The last line for each scheduling algorithm should have the average waiting time.
Example: As shown in the example below, when the algorithm is RR, there should be an integer parameter next to the algorithms name specifying the length of the time quantum:
RR 4
3
1 0 24 1
2 0 3 1
3 0 3 1
Output 1
RR
1
4 2
7 3
10 1
14 1
18 1
22 1
26 1
AVG Waiting Time: 5.67
Here is the code I have so far:
#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
