CPU scheduling is a process of determining which processes run when there are multiple runnable processes. The goal of CPU scheduling is faster computation which is also fair and efficient.
In this assignment, you will create a PCB (Process Control Block) class which holds the information of a process such as id, arrival time, start time, end time and burst time(job time). All possible class variables should be initialized in the constructor by reading the input file. Hence number of PCB objects is determined by the input file.
Create a Scheduler class. It should enqueue the PCB objects into a STL Queue based on the arrival time and dequeue a PCB object whenever the CPU is free. Calculate whether CPU is free based on the allocation time + burst time of the previous PCB object. Assume CPU is free for the initial case.
To Summarize the steps
Programming concepts that are expected in the solution:
Sample Input
ID Arrival Burst
#1 1 8
#2 3 2
#3 4 6
#4 8 2
#5 12 1
Sample Output
At clock 0: CPU Available
PCB Queue (empty)
At clock 1: PCB #1 enqueued
PCB #1 dequeued
CPU Busy(PCB #1 [1/8] )
PCB Queue (empty)
At clock 2: CPU Busy(PCB #1 [2/8])
PCB Queue (empty)
At clock 3: PCB #2 enqueued
CPU Busy(PCB #1 [3/8])
PCB Queue (PCB #2)
At clock 4: PCB #3 enqueued
CPU Busy(PCB #1 [4/8])
PCB Queue (PCB #2, PCB #3)
At clock 5: CPU Busy(PCB #1 [5/8])
PCB Queue (PCB #2, PCB #3)
At clock 6: CPU Busy(PCB #1 [6/8])
PCB Queue (PCB #2, PCB #3)
At clock 7: CPU Busy(PCB #1 [7/8])
PCB Queue (PCB #2, PCB #3)
At clock 8: PCB #4 enqueued
PCB #1 done
CPU available
PCB Queue (PCB #2, PCB #3, PCB #4)
At clock 9: PCB #2 dequeued
CPU Busy(PCB #2 [1/2])
PCB Queue (PCB #3, PCB #4)
At clock 10: PCB #2 done
CPU Available
PCB Queue (PCB #3, PCB #4)
At clock 11: PCB #4 dequeued
CPU Busy(PCB #4 [1/2])
PCB Queue (PCB #3)
At clock 12: PCB #5 enqueued
PCB #4 done
CPU Available
PCB Queue (PCB #3, PCB #5)
At clock 13: PCB #5 dequeued
PCB #5 done
CPU Available
PCB Queue (PCB #3)
At clock 14: PCB #3 dequeued
CPU Busy(PCB #3 [1/6])
PCB Queue (Empty)
At clock 15: CPU Busy(PCB #3 [2/6])
PCB Queue (Empty)
At clock 16: CPU Busy(PCB #3 [3/6])
PCB Queue (Empty)
At clock 17: CPU Busy(PCB #3 [4/6])
PCB Queue (Empty)
At clock 18: CPU Busy(PCB #3 [5/6])
PCB Queue (Empty)
At clock 19: PCB #3 done
CPU Available
PCB Queue (Empty)
At clock 20: CPU Available
PCB Queue (Empty)
Summary:
ID Arrival Burst Completion Turnaround Waiting
#1 1 8 8 8 0
#2 3 2 10 8 6
#3 4 6 19 16 10
#4 8 2 12 5 3
#5 12 1 13 2 1