Round Robin Scheduling in Operating System (original) (raw)

Last Updated : 6 Jan, 2026

Round Robin Scheduling is a method used by operating systems to manage the execution time of multiple processes that are competing for CPU attention. It is called "round robin" because the system rotates through all the processes, allocating each of them a fixed time slice or "quantum", regardless of their priority.

The primary goal of this scheduling method is to ensure that all processes are given an equal opportunity to execute, promoting fairness among tasks.

round_robinn

Round Robin Flow Chart

Example:

To understand the Round Robin Scheduling algorithm, let’s consider the following two scenarios:

Scenario 1: Processes with Same Arrival Time

Consider the following table of arrival time and burst time for three processes P1, P2 and P3 and given **Time Quantum = 2 ms

**Process **Burst Time **Arrival Time
P1 4 ms 0 ms
P2 5 ms 0 ms
P3 3 ms 0 ms

**Step-by-Step Execution:

  1. **Time 0-2 (P1): P1 runs for 2 ms (total time left: 2 ms).
  2. **Time 2-4 (P2): P2 runs for 2 ms (total time left: 3 ms).
  3. **Time 4-6 (P3): P3 runs for 2 ms (total time left: 1 ms).
  4. **Time 6-8 (P1): P1 finishes its last 2 ms.
  5. **Time 8-10 (P2): P2 runs for another 2 ms (total time left: 1 ms).
  6. **Time 10-11 (P3): P3 finishes its last 1 ms.
  7. **Time 11-12 (P2): P2 finishes its last 1 ms.
Gantt Chart:

Now, lets calculate average waiting time and turn around time:

Processes AT BT CT TAT WT
P1 0 4 8 8-0 = 8 8-4 = 4
P2 0 5 12 12-0 = 12 12-5 = 7
P3 0 3 11 11-0 = 11 11-3 = 8

Scenario 2: Processes with Different Arrival Times

Consider the following table of arrival time and burst time for three processes P1, P2 and P3 and given **Time Quantum = 2

**Process **Burst Time (BT) **Arrival Time (AT)
P1 5 ms 0 ms
P2 2 ms 4 ms
P3 4 ms 5 ms

Step-by-Step Execution:

**1. Time 0-2 (P1 Executes):

**2. Time 2-4 (P1 Executes Again):

**3. Time 4-6 (P2 Executes):

**4. Time 6-7 (P1 Executes):

**5. Time 7-9 (P3 Executes):

**6. Time 9-11 (P3 Executes Again):

**Gantt Chart:
Now, lets calculate average waiting time and turn around time:
**Process **Completion Time (CT) **Turnaround Time (TAT = CT - AT) **Waiting Time (WT = TAT - BT)
P1 7 ms 7 ms 2 ms
P2 6 ms 2 ms 0 ms
P3 11 ms 6 ms 2 ms

Code Implementation:

Advantages of Round Robin Scheduling

Disadvantages of Round Robin Scheduling: