Example of Round Robin Scheduling Algorithm
Example of Round Robin Scheduling Algorithm
Consider the following 6 processes: P1, P2, P3, P4, P5, and P6 with their arrival time
and burst time as given below:
Q. What are the average waiting and turnaround times for the round-robin scheduling
algorithm (RR) with a time quantum of 4 units?
Ready Queue:
At first, In the ready queue, process P1 will be executed for a time slice of 4 units.
Since there are no processes initially, Process P1, with a burst time of 5 units, will be
the only process in the ready queue.
P1
5
Ready Queue:
Along with the execution of P1, four more processes, P2, P3, P4, and P5, arrive in the
ready queue. P1 will be added to the ready queue due to the remaining 1 unit.
P2 P3 P4 P5 P1
6 3 1 5 1
Ready Queue:
During the execution of P2, P6 arrived in the ready queue. Since P2 has not been
completed, P2 will be added to the ready queue.
P3 P4 P5 P1 P6 P2
3 1 5 1 4 2
Ready Queue:
Similarly, P3 and P4 have been completed, but P5 has a remaining burst time of 1
unit. Hence it will be added back to the queue.
P1 P6 P2 P5
1 4 2 1
Ready Queue:
The next processes, P6 and P2, will be executed. Only P5 will be left with 1 unit of
burst time.
P5
GANTT Chart:
The Gantt chart will look like this:
As we know,
Processes Arrival Time(AT) Burst Time(BT) Turn Around Time(TAT) Waiting Time(WT)
P1 0 5 17 12
P2 1 6 22 16
Processes Arrival Time(AT) Burst Time(BT) Turn Around Time(TAT) Waiting Time(WT)
P3 2 3 9 6
P4 3 1 9 8
P5 4 5 20 15
P6 6 4 15 11