---
title: "Explain the Round Robin Scheduling algorithm with an example in OS."  
description: "Explain the Round Robin Scheduling algorithm with an example in OS."  
author: "Revati S Misra"  
published: 2023-03-31  
updated: 2023-03-31  
canonical: https://www.mindstick.com/forum/157665/explain-the-round-robin-scheduling-algorithm-with-an-example-in-os  
category: "Operating System"  
tags: ["windows", "operating system"]  
reading_time: 2 minutes  

---

# Explain the Round Robin Scheduling algorithm with an example in OS.

What is the [Round](https://answers.mindstick.com/qa/45311/what-was-the-agenda-of-the-round-table-conference-1930-1932) Robin [Scheduling](https://answers.mindstick.com/qa/103602/how-to-scheduling-a-call-on-skype) [algorithm in operating](https://answers.mindstick.com/qa/96691/what-is-banker-s-algorithm-in-operating-system) [systems](https://www.mindstick.com/articles/85451/best-travel-systems-for-newborns-to-pick)? [Explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) with an example.

## Replies

### Reply by Krishnapriya Rajeev

The Round Robin (RR) scheduling [algorithm](https://www.mindstick.com/blog/119/implementing-cryptography-in-c-sharp-dot-net-by-using-sha1-algorithm) is a preemptive scheduling algorithm used by the operating system to allocate CPU time to processes. In this algorithm, each process is assigned a *time slice or quantum*, and the CPU is allocated to each process for a fixed time slice, regardless of whether the process has completed its execution or not.

Let's take an example to understand this algorithm:

Suppose there are three processes, P1, P2, and P3, that require CPU time to execute. The time quantum is 4 units. The arrival time and burst time for each process are as follows:

| Process ID | Burst Time | Arrival Time |
| --- | --- | --- |
| P1 | 14 | 0 |
| P2 | 2 | 4 |
| P3 | 9 | 8 |

The RR algorithm assigns the CPU time to the processes in a cyclic order, giving each process a time slice of 4 units of time. Therefore, the CPU time is first assigned to P1, then P2, and P3, and the cycle repeats until all processes are completed. If a process has completed its execution within the time slice, the CPU is allocated to the next process in the queue.

The Gantt chart for the execution of the processes using the RR algorithm is as follows:

```plaintext
	P1		P2		P1		P3		P1		P3		P1		P3
_________________________________________________________________
0		4		6		10		14		18		22		24		25
```

As you can see from the Gantt chart, each process is assigned a time slice of 4 units of time. P1 is assigned the CPU time first and executes for 4 units of time. Then, the CPU time is allocated to P2, which executes for 2 units of time and finishes its execution. P3 is allocated the CPU time next and executes for 4 units of time. The cycle then repeats until all the processes are completed.

The RR algorithm provides fairness among processes and ensures that no process is starved for CPU time for a long time. However, it may cause overhead due to *frequent context switching*, which can affect the system's performance.


---

Original Source: https://www.mindstick.com/forum/157665/explain-the-round-robin-scheduling-algorithm-with-an-example-in-os

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
