Round Robin (RR) Scheduling Examples
Round Robin (RR) scheduling is a CPU scheduling algorithm used by OS to manage multiple processes waiting for CPU time. Round Robin (RR) scheduling assigns a fixed time quantum to each process, also called a time slice. For any process, if the quantum period expires and the process still needs some more CPU time, then that process is appended to the ready queue for its next turn, and the CPU moves to the next process in the ready queue. Round Robin (RR) scheduling is cyclic in nature, so there is no starvation
The main aim of Round Robin (RR) scheduling is to provide fair and balanced CPU allocation to each process for its execution. It is the best case in a time-sharing and multitasking environment.
Important Note:
|
In this article, we will see various examples of Round Robin (RR) scheduling in OS
Round Robin (RR) Scheduling Example 01
Consider the following table where arrival time and burst time are given for the processes P1, P2, P3, and P4 with a given Time Quantum = 5 ms

Gantt Chart and Ready Queue Behaviour
At time 0, processes P1, P2, P3, and P4 arrive, and it is placed in the ready queue. CPU will get P1 now, and the Gantt chart will start

At time 5, P1 is preempted after a quantum period of 5ms and added to the end of the ready queue. CPU now executes the next process in the ready queue, which is P2
P1 is preempted and added to the end of the ready queue because its quantum period has expired after 5ms. Since P1 has a total burst time of 5 ms, it has already executed for 5 ms. Therefore, its remaining burst time is:
Thus, P1 is placed back into the ready queue with a remaining burst time of 16ms. |

At time 8, P2 (having a burst time of 3ms) completes its execution at time 8ms. CPU now executes the next process in the ready queue, which is P3

At time 13, P3 is preempted after a quantum period of 5ms and added to the end of the ready queue. CPU now executes the next process in the ready queue, which is P4

At time 15, P4 (having burst time of 2ms) completes its execution at time 15ms. CPU now executes the next process in the ready queue, which is P1

At time 20, P1 is preempted after a quantum period of 5ms and added to the end of the ready queue. CPU now executes the next process in the ready queue, which is P3

At time 21, P3 (having a burst time of 1ms) completes its execution at time 21ms. CPU now executes the next process in the ready queue, which is P1

At time 26, P1 is preempted after a quantum period of 5ms and added to the end of the ready queue. CPU now executes the next process in the ready queue, which is P1

At time 31, P1 is preempted after a quantum period of 5ms and added to the end of the ready queue. CPU now executes the next process in the ready queue, which is P1

At time 32, P2 completes its execution at time 32ms. CPU now executes the next process in the ready queue; the ready queue is empty. That’s all

All calculations of the given example of RR are given below

Round Robin (RR) Scheduling Example 02
Consider the following table where arrival time and burst time are given for the processes P1, P2, P3, P4, and P5 with a given Time Quantum = 5 ms

Gantt Chart and Ready Queue Behaviour
At time 0, only process P1 arrives, and it is placed in the ready queue. CPU will get P1 now, and the Gantt chart will start

At time 0-3, P3 arrives, which is added to the end of the queue, and P1 is preempted after a quantum period of 3ms and added to the end of the ready queue. CPU now executes the next process in the ready queue, which is P3
P1 is preempted and added to the end of the ready queue because its quantum period has expired after 3ms. Since P1 has a total burst time of 8 ms, it has already executed for 3 ms. Therefore, its remaining burst time is:
Thus, P1 is placed back into the ready queue with a remaining burst time of 5 ms. |

At time 3-6, P2 and P4 arrive, which are added to the end of the queue, and P3 is preempted after a quantum period of 3ms and added to the end of the queue for its remaining burst time (7ms – 3ms = 4ms). CPU now executes the next process in the ready queue, which is P1

At time 6-9, P5 arrives, which is added to the end of the queue, and P1 is preempted after a quantum period of 3ms and added to the end of the queue for its remaining burst time (7ms – 3ms = 4ms). CPU now executes the next process in the ready queue, which is P2

At time 11, P2 (having a burst time of 2ms) completes its execution at time 11ms. CPU now executes the next process in the ready queue, which is P4

At time 14, P4 (having a burst time of 3ms) completes its execution at time 14ms. CPU now executes the next process in the ready queue, which is P3

At time 17, P3 is preempted after a quantum period of 3ms and added to the end of the queue for its remaining burst time (4ms – 3ms = 1ms). CPU now executes the next process in the ready queue, which is P5

At time 20, P5 is preempted after a quantum period of 3ms and added to the end of the queue for its remaining burst time (5ms – 3ms = 2ms). CPU now executes the next process in the ready queue, which is P1

At time 22, P1 (having a remaining burst time of 2ms) completes its execution at time 22ms. CPU now executes the next process in the ready queue, which is P3

At time 23, P3 (having a remaining burst time of 1ms) completes its execution at time 23ms. CPU now executes the next process in the ready queue, which is P5

At time 25, P5 (having a remaining burst time of 2ms) completes its execution at time 25ms. CPU now executes the next process in the ready queue, but ready queue is empty.

All calculations of the given example of RR are given below
