Write a C program that simulates CPU Scheduling Algorithms. Your program should support only uniprocessor mode and implement the following scheduling algorithms:
As this is a simple CPU scheduling simulator, you're not required to simulate I/O operations, I/O waiting state, interrupts, and/or context switches. However, you should implement your own queue, priority queue, and any other relevant data structure you might need.
Your program will read the information about each process from a file. The first line of the input file should contain a single integer n which represents the number of processes which each of your scheduling algorithms will use. This number will be between 1 and 1000. Following the first line, there will be n lines where each of them will contain 4 integers separated by a single space. The meaning of these integers is as follows:
Do note that the lines in the input file will be ordered by the process's arrival time. That said, an example of the input file would be as follows:
10
1 7 75 76
2 73 92 18
3 26 107 42
4 82 115 31
5 89 153 34
6 92 174 48
7 17 246 53
8 90 303 28
9 42 328 61
10 78 372 77
Your program should run all simulators for the provided input. Once all the simulations are complete, your program should output the following report:
To test your program for accuracy use the following C program to generate the relevant program inputs. Do note that to successfully compile this program you need to use the following command: gcc -o gen_scenario gen_scenario.c -std=c99
gen_scenario.c:
#include (stdio.h)
#include (stdlib.h)
#include (time.h)
int gen_random( int min, int max ) {
return min + rand( ) % max;
}
void gen_scenario( int i ) {
int j = 0;
printf( "%dn", i );
for( int j1 = 0; j1 ( i; j1++ ) {
int k = gen_random( 0, 100 );
int l = gen_random( 5, 100 );
int i1 = gen_random( 0, 99 );
printf( "%d %d %d %dn", j1 + 1, i1, j + k, l );
j += k;
}
}
int main( int argc, char* argv[ ] ) {
srand( time( NULL ) );
if( argc ) 1 ) {
gen_scenario( atoi( argv[ 1 ] ) );
} else {
gen_scenario( 10 );
}
return 0;
}
The gen_scenario program will generate process inputs up to the number you’ve specified in the command line argument or up to 10-process inputs otherwise.