In: Computer Science
An operating system uses the Round Robin (RR) without priority CPU scheduling algorithm, with a quantum = 4.
Consider the following set of processes in this OS, with the length of the CPU burst time given in milliseconds, and the shown priority.
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.
Process | Burst Time | Priority |
P1 | 5 | 2 |
P2 | 10 | 5 |
P3 | 4 | 1 |
P4 | 6 | 4 |
P5 | 9 | 3 |
a) Draw a Gantt chart illustrating the order of execution of these processes, showing their completion times.
b) Calculate each process’ waiting time, and then compute the average waiting time for this set.
Note: waiting time = completion time – arrival time – burst time
=> Write your answers on scratch paper (make sure it is visible) then take a picture of it and upload it here.
The below information is given in the problem:
Process |
Burst Time |
P1 |
5 |
P2 |
10 |
P3 |
4 |
P4 |
6 |
P5 |
9 |
Round robin is a CPU scheduling algorithm in which the processes are allocated a fixed time slice know as quantum in a circular way.
The priority of the process should be ignored as it is given in the problem that we have to compute values for RR without priority
Using Round Robin scheduling these processes will be scheduled as per below Gantt Chart:
The completion time of a process is calculated as the time at which process completes its execution
The turnaround time is the time difference between completion
time and arrival time
Turnaround time = Completion time - Arrival time
The Waiting time is the time difference between turnaround time and
burst time.
Waiting Time = Turnaround time - Burst Time
So using the Gantt chart and formula above we can compute the
Turnaround time and waiting
time as follows :
Quantum = 4
Process |
Burst Time |
Waiting Time |
Turnaround Time |
P1 |
5 |
16 |
21 |
P2 |
10 |
23 |
33 |
P3 |
4 |
8 |
12 |
P4 |
6 |
21 |
27 |
P5 |
9 |
25 |
34 |
B) Average Waiting Time
Process |
Waiting Time=Completion Time – Arrival Time – Burst time |
P1 |
21 – 0 – 5 = 16 |
P2 |
33 – 0 – 10 = 23 |
P3 |
12 – 0 – 4 = 8 |
P4 |
27 – 0 – 6 = 21 |
P5 |
34 – 0 – 9 = 25 |
Average waiting time = Sum of waiting time for each process / Number of processes
Average Waiting Time = (16 + 23 + 8 + 21 + 25) / 5 = 18.6 ms