Lab 6 - Process Scheduling Simulation


Due Date: Midnight Friday July 9

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    4
Where A is a unique identifier for the process, 10 is the amount of time the process will run, and 4 is 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   3
Should 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 40
A Gantt chart can be used to model the execution of each process:
C C A A A A A A A A A A B F B F B F B F B F B F B F B F F F E E E E E E D D D D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

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.