Build this in C Build a partially-completed program that analyzes different CPU scheduling algorithms. The driver software
Question:
Build this in C Build a partially-completed program that analyzes different CPU scheduling algorithms. The driver software for the analysis program is already complete. Below is the usage message displayed by the driver. Usage: a.out <#processes> -user Usage: a.out <#processes> -random <#processes> : Positive integer : Positive integer : Positive integer The choice of "-user" tells the program to prompt the user and read in each process running time from the keyboard. The choice of "-random" tells the program to randomly generate the running times with as the maximum running time. The program stores all process information in an array of records that is passed to each scheduling algorithm. Information on the format of the record and the use of each field are described in later sections of this document. Your assignment is to build this program by implementing a simulation of the First Come, First Served (FCFS), non-preemptive Shortest Job First (SJF), and Round Robin scheduling algorithms (as demonstrated in class), and printing the analysis results of those simulations. All results shall be sent to standard out and use the buffered I/O functions (e.g, printf()). All times are assumed to be in milliseconds. Your analysis shall show the results of running the entire set of processes in a time-sharing approach on one CPU using each of the scheduling algorithms. The analysis shall assume that each process initially arrives in the ready queue at the same time as the other processes. It shall also assume that after a process is given the CPU to use, the process gives up the CPU only after its allotted time ends. The analysis results shall consist of a table of time data for each algorithm and then a summary of that data as shown in the sample-run.txt file. (Note that the driver module prints the text denoting the start of each table.) The table of time data shall show the time usage for each process and shall be formatted as shown in the sample run file. The summary information printed below the table shall show the average waiting time and the average turn-around time for that scheduling algorithm. The average waiting time is the average of the total amount of time that each process spends waiting in the ready queue. The average turn-around time is the average of the final completion time for each of the processes. Note that for the Shortest Job First algorithm, it works the same as the FCFS algorithm. You just need to sort the jobs first. For an illustration of how to doo this sort, see the sortDemo.c file. Note that for the Round Robin algorithm, each process shall run in sequence for its allotted quantum time starting with process zero. Also note that for the round robin report, the summary information shall also show the time quantum that was used (i.e., that was provided by the user on the command line). This the how the output will look like C:\> a.exe 8 5 -random 17 ** Analysis Options ** Total number of processes to analyze : 8 Quantum time used in round robin analysis : 5 msec Randomly generate process running times : Yes Maximum total running time of a process : 17 msec Generating running times for 8 processes . . . This analysis report was generated on Mon Mar 19 18:07:39 2012 ** START OF ANALYSIS REPORT ** ** First Come, First Served (FCFS) Scheduling ** Process# Start Time Stop Time Running Time -------- ---------- --------- ------------ 0 0 5 5 1 5 22 17 2 22 30 8 3 30 45 15 4 45 49 4 5 49 54 5 6 54 69 15 7 69 82 13 Average waiting time: 34.25 msec Average turn-around time: 44.50 msec ** Shortest Job First (SJF) Scheduling ** Process# Start Time Stop Time Running Time -------- ---------- --------- ------------ 4 0 4 4 0 4 9 5 5 9 14 5 2 14 22 8 7 22 35 13 3 35 50 15 6 50 65 15 1 65 82 17 Average waiting time: 24.88 msec Average turn-around time: 35.12 msec ** Round Robin (RR) Scheduling ** Process# Start Time Stop Time Running Time -------- ---------- --------- ------------ 0 0 5 5 1 5 10 5 2 10 15 5 3 15 20 5 4 20 24 4 5 24 29 5 6 29 34 5 7 34 39 5 1 39 44 5 2 44 47 3 3 47 52 5 6 52 57 5 7 57 62 5 1 62 67 5 3 67 72 5 6 72 77 5 7 77 80 3 1 80 82 2 Time quantum: 5 msec Average waiting time: 41.75 msec Average turn-around time: 52.00 msec ** END OF ANALYSIS REPORT **
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr