Solving the Round Robin (RR) Scheduling Algorithm
Given Data:
- Processes: P1, P2, P3
- Burst Times (BT):
- P1 = 24
- P2 = 3
- P3 = 3
- Time Quantum = 4
Step 1: Gantt Chart Construction
Using a time quantum of 4, we allocate the CPU to each process in a round-robin manner.
- Time Slice 1:
- P1 executes for 4 units (remaining = 24 – 4 = 20).
- P2 completes execution (remaining = 3 – 3 = 0).
- P3 completes execution (remaining = 3 – 3 = 0).
- Time Slice 2:
- P1 executes for another 4 units (remaining = 20 – 4 = 16).
- Repeat Process:
- P1 continues to execute until it completes.
Gantt Chart
| Time | Process |
|---|---|
| 0 – 4 | P1 |
| 4 – 7 | P2 |
| 7 – 10 | P3 |
| 10 – 14 | P1 |
| 14 – 18 | P1 |
| 18 – 22 | P1 |
| 22 – 26 | P1 |
| 26 – 30 | P1 |
Step 2: Completion Time
- P1: Finishes at t=30t = 30t=30
- P2: Finishes at t=7t = 7t=7
- P3: Finishes at t=10t = 10t=10
Step 3: Turnaround Time (TAT)
Step 3: Turnaround Time (TAT)
TAT=Completion Time (CT)−Arrival Time (AT)
| Process | Completion Time (CT) | Arrival Time (AT) | Turnaround Time (TAT) |
|---|---|---|---|
| P1 | 30 | 0 | 30 |
| P2 | 7 | 0 | 7 |
| P3 | 10 | 0 | 10 |
Step 4: Waiting Time (WT)
WT=TAT−Burst Time (BT)
| Process | Turnaround Time (TAT) | Burst Time (BT) | Waiting Time (WT) |
|---|---|---|---|
| P1 | 30 | 24 | 6 |
| P2 | 7 | 3 | 4 |
| P3 | 10 | 3 | 7 |
Final Results:
| Process | Burst Time (BT) | Completion Time (CT) | Turnaround Time (TAT) | Waiting Time (WT) |
|---|---|---|---|---|
| P1 | 24 | 30 | 30 | 6 |
| P2 | 3 | 7 | 7 | 4 |
| P3 | 3 | 10 | 10 | 7 |
Average Times:
- Average Turnaround Time (TAT):Average TAT=30+7+10/3=15.67
- Average Waiting Time (WT):Average WT=6+4+7/3=5.67