Example:
Given Processes:
| Process | Arrival Time | Burst Time |
|---|---|---|
| P1 | 0 | 6 |
| P2 | 1 | 8 |
| P3 | 2 | 7 |
| P4 | 3 | 3 |
Time Quantum: 4
Step 1: Process Execution
- At
t=0, P1 gets the CPU for 4 units. Remaining burst time: 2. - At
t=4, P2 executes for 4 units. Remaining burst time: 4. - At
t=8, P3 executes for 4 units. Remaining burst time: 3. - At
t=12, P4 executes for 3 units. Remaining burst time: 0 (P4 finishes). - Back to P1, executes for 2 units (finishes at
t=17). - P2 resumes, executes for 4 units (finishes at
t=21). - 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
| Process | Arrival Time | Burst Time | Completion Time | TAT | WT |
|---|---|---|---|---|---|
| P1 | 0 | 6 | 17 | 17 | 11 |
| P2 | 1 | 8 | 21 | 20 | 12 |
| P3 | 2 | 7 | 24 | 22 | 15 |
| P4 | 3 | 3 | 15 | 12 | 9 |
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
- Fair for all processes.
- Prevents starvation.
- Simple to implement.
Disadvantages of Round Robin
- High context switching overhead.
- Performance depends heavily on the time quantum:
- A very small quantum increases overhead.
- A very large quantum reduces responsiveness and approximates FCFS scheduling.