RR Scheduling Algorithm: Complete Guide with 5 Powerful Examples

On: October 14, 2025
RR Scheduling Algorithm

The Round Robin (RR) Scheduling Algorithm is one of the simplest and most widely used CPU scheduling algorithms in operating systems. It ensures that every process gets an equal share of CPU time, making it fair and efficient for time-sharing systems.

In this algorithm, each process is assigned a fixed time slot called a time quantum or time slice. The CPU executes a process for this specific time. If the process is not completed within that period, it is moved to the back of the ready queue, and the CPU is allocated to the next process.

How Round Robin Scheduling Works

Here’s a step-by-step explanation of how the RR scheduling algorithm works:

  1. All processes are placed in a ready queue (FIFO order).
  2. The CPU scheduler picks the first process from the queue.
  3. The process runs for a fixed time quantum.
  4. If the process finishes within that time, it leaves the queue.
  5. If not, it is sent back to the end of the queue, and the next process gets the CPU.
  6. This cycle continues until all processes are complete.

This way, every process gets a fair chance to execute, preventing starvation in os.

Example of Round Robin Scheduling

Let’s take a simple example:

ProcessBurst TimeTime Quantum = 3 ms
P15 ms
P23 ms
P38 ms

Execution Order:
P1 (3 ms) → P2 (3 ms) → P3 (3 ms) → P1 (2 ms) → P3 (5 ms)

Here, every process runs for 3 milliseconds before moving to the next one.

C Program : RR Scheduling Algorithm

#include <stdio.h>

int main() {
    int n, quantum;
    int bt[20], wt[20], tat[20], rem_bt[20];
    int i, t = 0, total_wt = 0, total_tat = 0;

    printf("Enter total number of processes: ");
    scanf("%d", &n);

    printf("Enter burst time for each process:\n");
    for (i = 0; i < n; i++) {
        printf("P%d: ", i + 1);
        scanf("%d", &bt[i]);
        rem_bt[i] = bt[i]; // store remaining burst time
    }

    printf("Enter Time Quantum: ");
    scanf("%d", &quantum);

    while (1) {
        int done = 1;
        for (i = 0; i < n; i++) {
            if (rem_bt[i] > 0) {
                done = 0; // There is a pending process

                if (rem_bt[i] > quantum) {
                    t += quantum;
                    rem_bt[i] -= quantum;
                } else {
                    t += rem_bt[i];
                    wt[i] = t - bt[i];
                    rem_bt[i] = 0;
                }
            }
        }

        if (done == 1)
            break;
    }

    // Calculate Turnaround Time
    for (i = 0; i < n; i++) {
        tat[i] = bt[i] + wt[i];
        total_wt += wt[i];
        total_tat += tat[i];
    }

    printf("\nProcess\tBurst Time\tWaiting Time\tTurnaround Time\n");
    for (i = 0; i < n; i++) {
        printf("P%d\t\t%d\t\t%d\t\t%d\n", i + 1, bt[i], wt[i], tat[i]);
    }

    printf("\nAverage Waiting Time = %.2f", (float)total_wt / n);
    printf("\nAverage Turnaround Time = %.2f\n", (float)total_tat / n);

    return 0;
}

Sample Output

Enter total number of processes: 3
Enter burst time for each process:
P1: 5
P2: 3
P3: 8
Enter Time Quantum: 3

Process	Burst Time	Waiting Time	Turnaround Time
P1		5		6		11
P2		3		3		6
P3		8		9		17

Average Waiting Time = 6.00
Average Turnaround Time = 11.33

Advantages of RR Scheduling Algorithm

  • Fair Allocation: Each process gets equal CPU time.
  • Good for Time-Sharing Systems: Best suited for multitasking environments.
  • Responsive: Short processes finish quickly without long waiting times.
  • Simple and Easy to Implement: Works on a straightforward queue-based approach.

Disadvantages of RR Scheduling Algorithm

  • Context Switching Overhead: Frequent switching can reduce performance.
  • Time Quantum Selection: Choosing the right quantum is tricky—too small increases overhead, too large reduces responsiveness.
  • Not Ideal for Long Tasks: Processes with longer burst times might take longer to complete.

Characteristics of RR Scheduling Algorithm

  • Scheduling Type: Preemptive
  • CPU Utilization: Moderate to High
  • Starvation: Not possible
  • Best Suited For: Time-sharing systems and interactive users

Formula to Calculate Waiting Time and Turnaround Time

  • Waiting Time (WT): Turnaround Time – Burst Time
  • Turnaround Time (TAT): Completion Time – Arrival Time

These formulas help calculate performance metrics in CPU scheduling problems.

Real-World Use of RR Scheduling Algorithm

Round Robin scheduling is widely used in time-sharing operating systems, such as UNIX and Linux, where each user or process gets equal CPU attention for short bursts.

Final Thoughts

The Round Robin (RR) Scheduling Algorithm is one of the easiest and most fair scheduling methods. It ensures equal CPU distribution, low waiting time for short processes, and efficient multitasking. However, its performance highly depends on the time quantum selection.

Interview Questions You May Face on RR Scheduling Algorithm

When preparing for Operating System or Embedded Software interviews, you might face questions like:

  1. What is the main idea behind the RR scheduling algorithm?
  2. How is Round Robin different from FCFS or SJF scheduling?
  3. Why is RR considered preemptive?
  4. What is the effect of choosing a small or large time quantum?
  5. Can starvation occur in RR scheduling? Why or why not?
  6. Write a program to simulate RR scheduling in C.
  7. Explain the formula for waiting time and turnaround time in RR.
  8. What kind of systems use RR scheduling in real life?
  9. How do context switches affect CPU performance?
  10. What are the advantages and disadvantages of RR compared to Priority Scheduling?

Frequently Asked Questions (FAQs) about RR Scheduling Algorithm

1. What is the RR Scheduling Algorithm in Operating System?

The RR (Round Robin) Scheduling Algorithm is a preemptive CPU scheduling technique where each process gets an equal fixed time to execute, known as a time quantum. If a process doesn’t finish in that time, it goes to the back of the queue.

2. Why is it called Round Robin?

It’s called Round Robin because CPU time is given to each process in a circular order, like players taking turns in a game — ensuring fair CPU allocation.

3. What is a Time Quantum in RR Scheduling?

A time quantum (or time slice) is the fixed amount of CPU time allocated to each process. After this time expires, the CPU switches to the next process.

4. Is Round Robin Scheduling Preemptive or Non-Preemptive?

Round Robin Scheduling is preemptive because the CPU forcibly switches from one process to another after the time quantum expires, even if the current process isn’t finished.

5. What are the main advantages of RR Scheduling?

  • Fair CPU sharing among processes
  • No starvation (every process gets CPU time)
  • Suitable for time-sharing systems
  • Good response time for interactive tasks

6. What are the disadvantages of RR Scheduling?

  • Too many context switches if the time quantum is too small
  • Hard to select the ideal time quantum
  • Performance decreases with long burst-time processes

7. How do you calculate waiting time and turnaround time in RR?

  • Waiting Time (WT) = Turnaround Time – Burst Time
  • Turnaround Time (TAT) = Completion Time – Arrival Time

These metrics help measure CPU efficiency and responsiveness.

8. What is the best time quantum for Round Robin?

There’s no universal best value. However, a smaller quantum improves responsiveness but increases context switches. A larger quantum reduces context switches but may cause longer waiting times.

9. Where is Round Robin Scheduling used in real life?

Round Robin is used in time-sharing operating systems, like UNIX and Linux, where multiple users or processes share CPU time equally.

10. What is the main difference between RR and FCFS Scheduling?

  • FCFS (First Come First Serve) runs each process until it finishes.
  • RR (Round Robin) gives each process a fixed time and switches tasks regularly — making it more fair and interactive.

Leave a Comment

Exit mobile version