Round Robin (RR) Scheduling Algorithm

4
1

Introduction

Round Robin scheduling is a preemptive CPU scheduling algorithm based on a fixed time quantum. Each ready process gets the CPU for at most one time quantum before the scheduler moves to the next process.

It is especially useful in time-sharing systems, where the goal is not just to finish jobs quickly, but to give every active process regular CPU attention.

Core Rule of Round Robin Scheduling

Round Robin uses a ready queue. The process at the head of the queue gets the CPU and runs for one fixed time quantum.

After the quantum ends, two things can happen:

  • If the process finishes: It leaves the system.

  • If the process still has remaining time: It is preempted and placed at the tail of the ready queue.

Because the CPU can forcibly stop a running process after its quantum, Round Robin needs preemption, timer interrupts, and context switching.

Time Quantum Tradeoff

The time quantum controls the behavior of Round Robin. A smaller quantum improves response time because processes get CPU turns more frequently.

However, a very small quantum causes too many context switches, which increases overhead. A very large quantum reduces overhead, but Round Robin starts behaving closer to FCFS because most processes may finish in one turn.

Round Robin Scheduling Example

Consider four processes with arrival time and burst time:

Process

Arrival Time

Burst Time

P1

0

10

P2

1

5

P3

2

8

P4

3

4

Time Quantum = 4

Round Robin Scheduling Example

Round Robin Scheduling Example

The compact execution flow is:

  • P1 runs from 0 to 4 and still has remaining time.

  • P2 runs from 4 to 8 and still has remaining time.

  • P3 runs from 8 to 12 and still has remaining time.

  • P4 runs from 12 to 16 and finishes.

  • P1 runs again from 16 to 20.

  • P2 runs from 20 to 21 and finishes.

  • P3 runs from 21 to 25 and finishes.

  • P1 runs from 25 to 27 and finishes.

Process

CPU Time Interval

P1

0 to 4

P2

4 to 8

P3

8 to 12

P4

12 to 16

P1

16 to 20

P2

20 to 21

P3

21 to 25

P1

25 to 27

Metric Calculation

The main formulas are:

  • CT: time when a process finishes

  • TAT: CT - AT

  • WT: TAT - BT

  • RT: first CPU start time - AT

Process

CT

TAT

WT

RT

P1

27

27

17

0

P2

21

20

15

3

P3

25

23

15

6

P4

16

13

9

9

Average TAT = 20.75, average WT = 14.0, and average RT = 4.5.

Strengths and Weaknesses of Round Robin

Strengths

Weaknesses

Gives good response time

May increase turnaround time

Shares CPU fairly among ready processes

Small quantum causes many context switches

Works well for time-sharing systems

Large quantum behaves close to FCFS

Summary

Round Robin scheduling gives each ready process the CPU for at most one fixed time quantum. If the process finishes, it exits; otherwise, it is preempted and placed at the end of the ready queue.

It is fair, simple, and useful for time-sharing systems. Its main tradeoff is quantum selection: a small quantum improves response time but increases context-switching overhead, while a large quantum makes the algorithm behave closer to FCFS.

CS Core

Read Similar Blogs

Comments0