Round Robin Scheduling Algorithm with Example

โšก Smart Summary

Round-Robin Scheduling is the oldest and simplest preemptive CPU algorithm, where each ready process runs for a fixed time slice in a cyclic queue, ensuring fair, starvation-free execution for multitasking.

  • ๐Ÿ”„ Definition: Each ready task runs in turns for a fixed time slice.
  • โฑ๏ธ Time Quantum: The CPU switches processes after a fixed interval, the time quantum.
  • โš–๏ธ Fairness: Every process gets equal CPU time, avoiding starvation.
  • ๐Ÿงฎ Preemptive: A preempted process moves to the end of the queue.
  • โœ… Advantages: Fair allocation, no convoy effect, predictable response time.
  • โš ๏ธ Drawbacks: Performance depends on the time quantum and adds context-switch overhead.

Round Robin Scheduling Algorithm

What is Round-Robin Scheduling?

The name of this algorithm comes from the round-robin principle, where each person gets an equal share of something in turns. It is the oldest, simplest scheduling algorithm, which is mostly used for multitasking.

In Round-robin scheduling, each ready task runs turn by turn only in a cyclic queue for a limited time slice. This algorithm also offers starvation-free execution of processes.

Characteristics of Round-Robin Scheduling

Here are the important characteristics of Round-Robin Scheduling:

  • Round robin is a pre-emptive algorithm.
  • The CPU is shifted to the next process after a fixed interval of time, which is called time quantum/time slice.
  • The process that is preempted is added to the end of the queue.
  • Round robin is a hybrid model which is clock-driven.
  • The time slice should be minimum, which is assigned for a specific task that needs to be processed. However, it may differ from OS to OS.
  • It is a real-time algorithm which responds to the event within a specific time limit.
  • Round robin is one of the oldest, fairest, and easiest algorithms.
  • It is a widely used scheduling method in traditional OS.

Example of Round-robin Scheduling

Consider the following three processes:

Process Queue Burst time
P1 4
P2 3
P3 5

Round-robin Scheduling

Step 1) The execution begins with process P1, which has burst time 4. Here, every process executes for 2 seconds. P2 and P3 are still in the waiting queue.

Round-robin Scheduling

Step 2) At time = 2, P1 is added to the end of the Queue and P2 starts executing.

Round-robin Scheduling

Step 3) At time = 4, P2 is preempted and added at the end of the queue. P3 starts executing.

Round-robin Scheduling

Step 4) At time = 6, P3 is preempted and added at the end of the queue. P1 starts executing.

Round-robin Scheduling

Step 5) At time = 8, P1 has a burst time of 4. It has completed execution. P2 starts execution.

Round-robin Scheduling

Step 6) P2 has a burst time of 3. It has already executed for 2 intervals. At time = 9, P2 completes execution. Then, P3 starts execution till it completes.

Round-robin Scheduling

Step 7) Let us calculate the average waiting time for the above example.

Wait time
P1 = 0 + 4 = 4
P2 = 2 + 4 = 6
P3 = 4 + 3 = 7

Advantages of Round-robin Scheduling

Here are the pros/benefits of the Round-robin scheduling method:

  • It does not face the issues of starvation or convoy effect.
  • All the jobs get a fair allocation of CPU.
  • It deals with all processes without any priority.
  • If you know the total number of processes on the run queue, then you can also assume the worst-case response time for the same process.
  • This scheduling method does not depend upon burst time. That is why it is easily implementable on the system.
  • Once a process is executed for a specific set of the period, the process is preempted, and another process executes for that given time period.
  • Allows the OS to use the Context switching method to save states of preempted processes.
  • It gives the best performance in terms of average response time.

Disadvantages of Round-robin Scheduling

Here are the drawbacks/cons of using Round-robin scheduling:

  • If the slicing time of the OS is low, the processor output will be reduced.
  • This method spends more time on context switching.
  • Its performance heavily depends on time quantum.
  • Priorities cannot be set for the processes.
  • Round-robin scheduling does not give special priority to more important tasks.
  • It decreases comprehension.
  • A lower time quantum results in higher context switching overhead in the system.
  • Finding a correct time quantum is quite a difficult task in this system.

Worst Case Latency

This term is used for the maximum time taken for execution of all the tasks.

  • dt = Denotes detection time when a task is brought into the list
  • st = Denotes switching time from one task to another
  • et = Denotes task execution time

Formula:

Tworst = {(dti+ sti + eti ), + (dti+ sti + eti )2 +...+ (dti+ sti + eti )N., + (dti+ sti + eti  + eti) N} + tISR
tISR = sum of all execution times

FAQs

Time quantum, or time slice, is the fixed CPU time each process runs before it is preempted. Too large behaves like FCFS; too small adds heavy context-switching overhead.

FCFS runs each process to completion in arrival order and is non-preemptive. Round Robin is preemptive: it gives each process a fixed time slice and cycles through the queue, improving response time and preventing long jobs from blocking others.

Because every process is placed in a cyclic queue and receives a fixed time slice in turn. No process is skipped or indefinitely delayed, so each one eventually gets CPU time regardless of its length or arrival order.

AI and machine learning can predict process behavior and workload patterns to tune scheduling decisions in real time. Instead of a fixed policy, the system can adapt priorities and time slices dynamically, improving CPU utilization, throughput, and response time.

Yes. AI models can analyze past burst times and system load to suggest an optimal time quantum, and adjust it as conditions change. This balances context-switch overhead against response time better than a single fixed value.

Summarize this post with: