Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Round Robin Scheduling in Operating System
Next article icon

Round Robin Scheduling in Operating System

Last Updated : 24 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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.

Here's a simple breakdown:

  • Process Arrival: Processes enter the system and are placed in a queue.
  • Time Allocation: Each process is given a certain amount of CPU time, called a quantum.
  • Execution: The process uses the CPU for the allocated time.
  • Rotation: If the process completes within the time, it leaves the system. If not, it goes back to the end of the queue.
  • Repeat: The CPU continues to cycle through the queue until all processes are completed.
round_robinn
Round Robin Flow Chart

How Does It Work? - Imagine you're at a busy restaurant with a group of friends, and there's only one waiter. The waiter could spend a long time at one table, but instead, he choose to spend exactly one minute at each table before moving to the next. Similarly, in Round Robin Scheduling, the CPU spends a predetermined slice of time on each process. If a process hasn't finished its task by the time its slice is up, it's moved to the back of the queue, and the CPU moves on to the next process.

Advantages of Round Robin Scheduling

  • Fairness: Each process gets an equal share of the CPU.
  • Simplicity: The algorithm is straightforward and easy to implement.
  • Responsiveness: Round Robin can handle multiple processes without significant delays, making it ideal for time-sharing systems.

Disadvantages of Round Robin Scheduling:

  • Overhead: Switching between processes can lead to high overhead, especially if the quantum is too small.
  • Underutilization: If the quantum is too large, it can cause the CPU to feel unresponsive as it waits for a process to finish its time.

Example of Round Robin Scheduling Algorithm:

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

ProcessBurst TimeArrival Time
 P1   4 ms0 ms
 P2 5 ms0 ms
 P3 3 ms0 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:

  • Turnaround Time = Completion Time - Arrival Time
  • Waiting Time = Turnaround Time - Burst Time
ProcessesATBTCTTATWT
P10488-0 = 88-4 = 4
P2051212-0 = 1212-5 = 7
P3031111-0 = 1111-3 = 8
  • Average Turn around time = (8 + 12 + 11)/3 = 31/3 = 10.33 ms
  • Average waiting time = (4 + 7 + 8)/3 = 19/3 = 6.33 ms

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

ProcessBurst Time (BT)Arrival Time (AT)
P15 ms0 ms
P22 ms4 ms
P34 ms5 ms
Step-by-Step Execution:
  • Time 0-2 (P1 Executes):
    • P1 starts execution as it arrives at 0 ms.
    • Runs for 2 ms; remaining burst time = 5 - 2 = 3 ms.
    • Ready Queue: [P1].
  • Time 2-4 (P1 Executes Again):
    • P1 continues execution since no other process has arrived yet.
    • Runs for 2 ms; remaining burst time = 3 - 2 = 1 ms.
    • P2 arrive at 4 ms.
    • Ready Queue: [P2, P1].
  • Time 4-6 (P2 Executes):
    • P2 starts execution as it arrives at 4 ms.
    • Runs for 2 ms; remaining burst time = 2 - 2 = 0 ms.
    • P3 arrive at 5ms
    • Ready Queue: [P1, P3].
  • Time 6-7 (P1 Executes):
    • P1 starts execution.
    • Runs for 1 ms; remaining burst time = 1 - 1 = 0 ms.
    • Ready Queue: [P3].
  • Time 7-9 (P3 Executes):
    • P3 starts execution.
    • Remaining burst time = 4 - 2 = 2 ms.
    • Ready Queue: [P3].
  • Time 9-11 (P3 Executes Again):
    • P3 resumes execution and runs for 2 ms and complete its execution
    • Remaining burst time = 2 - 2 = 0 ms.
    • Ready Queue: [].
Gantt Chart:
Now, lets calculate average waiting time and turn around time:
ProcessCompletion Time (CT)Turnaround Time (TAT = CT - AT)Waiting Time (WT = TAT - BT)
P17 ms7 ms2 ms
P26 ms2 ms0 ms
P311 ms6 ms2 ms
  • Average Turn around time =7+2+6/3​=15/3=5ms
  • Average waiting time = 2+0+2/3=1.33ms

Code Implementation:

1. Program for Round Robin Scheduling for the Same Arrival Time

2. Program for Round Robin Scheduling with Different Arrival Times


Next Article
Round Robin Scheduling in Operating System

M

madhur912
Improve
Article Tags :
  • Operating Systems
  • CPU Scheduling

Similar Reads

    Priority Scheduling in Operating System
    Priority scheduling is one of the most common scheduling algorithms used by the operating system to schedule processes based on their priority. Each process is assigned a priority value based on criteria such as memory requirements, time requirements, other resource needs, or the ratio of average I/
    4 min read
    CPU Scheduling in Operating Systems
    CPU scheduling is a process used by the operating system to decide which task or process gets to use the CPU at a particular time. This is important because a CPU can only handle one task at a time, but there are usually many tasks that need to be processed. The following are different purposes of a
    8 min read
    I/O scheduling in Operating Systems
    Input/Output (I/O) operations are how a computer communicates with external devices such as hard drives, keyboards, printers, and network interfaces. These operations involve transferring data into and out of the system whether it’s reading a file, saving a document, printing, or sending data over a
    6 min read
    List scheduling in Operating System
    Prerequisite - CPU Scheduling List Scheduling also known as Priority List Based Scheduling is a scheduling technique in which an ordered list of processes are made by assigning them some priorities. So, basically what happens is, a list of processes that are ready to be executed at a given point is
    3 min read
    Process Schedulers in Operating System
    A process is the instance of a computer program in execution. Scheduling is important in operating systems with multiprogramming as multiple processes might be eligible for running at a time.One of the key responsibilities of an Operating System (OS) is to decide which programs will execute on the C
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences