Round Robin (RR Algorithm)

Example:

Given Processes:

ProcessArrival TimeBurst Time
P106
P218
P327
P433

Time Quantum: 4


Step 1: Process Execution

  1. At t=0, P1 gets the CPU for 4 units. Remaining burst time: 2.
  2. At t=4, P2 executes for 4 units. Remaining burst time: 4.
  3. At t=8, P3 executes for 4 units. Remaining burst time: 3.
  4. At t=12, P4 executes for 3 units. Remaining burst time: 0 (P4 finishes).
  5. Back to P1, executes for 2 units (finishes at t=17).
  6. P2 resumes, executes for 4 units (finishes at t=21).
  7. P3 resumes, executes for 3 units (finishes at t=24).

Gantt Chart

| Time | 0 – 4 | 4 – 8 | 8 – 12 | 12 – 15 | 15 – 17 | 17 – 21 | 21 – 24 | |——|——-|——-|——–|———|———|———| | P | P1 | P2 | P3 | P4 | P1 | P2 | P3 |


Step 2: Calculations

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

ProcessArrival TimeBurst TimeCompletion TimeTATWT
P106171711
P218212012
P327242215
P43315129

Step 3: Averages

  • Average Turnaround Time (TAT): 17+20+22+124=17.75\frac{17 + 20 + 22 + 12}{4} = 17.75417+20+22+12​=17.75
  • Average Waiting Time (WT): 11+12+15+94=11.75\frac{11 + 12 + 15 + 9}{4} = 11.75411+12+15+9​=11.75

Advantages of Round Robin

  1. Fair for all processes.
  2. Prevents starvation.
  3. Simple to implement.

Disadvantages of Round Robin

  1. High context switching overhead.
  2. Performance depends heavily on the time quantum:
    • A very small quantum increases overhead.
    • A very large quantum reduces responsiveness and approximates FCFS scheduling.

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *