One of the many responsibilities of a timesharing operating system is to provide each running program with its "fair" share of the CPU time. One of the scheduling algorithms used to determine when a process should be allowed to run is called priority scheduling. With this algorithm, each process is assigned a priority. Processes with higher priorities are executed before processes with lower priorities. A queue is maintained for each priority. Each process is dequeued, executed for some pre-defined amount of time, then reinserted into the queue, provided that it has not completed execution. There are conditions that cause processes to be temporally removed from the queue; however, we will not discuss those here.
For this lab, we will be implementing a process scheduler simulator. The pre-defined amount of time each process will be executed is 1 quantum (a single iteration through a loop). Each process entry will be newline delimited, and will be read from a file (use command line arguments) in the following form:
A 10 4Where
Ais a unique identifier for the process,
10is the amount of time the process will run, and
4is the priority of the process.
Your program should read in processes until EOF is reached, placing each process in the appropriate queue. Then your program should simulate execution of the processes and report the time at which each of the simulated programs terminate. A makefile is required.
The following sample input:
A 10 4 B 8 3 C 2 5 D 4 1 E 6 2 F 10 3Should produce the following output:
Process C finished at time 2 Process A finished at time 12 Process B finished at time 27 Process F finished at time 30 Process E finished at time 36 Process D finished at time 40A Gantt chart can be used to model the execution of each process:
To submit your lab:
Make sure all your files in your lab6 directory. Leave a readme file if you special instructions for comiling your program.