Round robin with a quantum of 4 — Aptitude Question
Round robin with a quantum of 4: Three processes arrive together at time 0, in the order P1, P2, P3: | Process |… Answer and worked solution on CodeKairo.
- Topic: OS, DBMS & Networks
- Section: Programming MCQs
- Difficulty: Medium
- Time target: 135 seconds
Question
Three processes arrive together at time 0, in the order P1, P2, P3:
| Process | Burst time |
|---|---|
| P1 | 24 |
| P2 | 3 |
| P3 | 3 |
Under round-robin scheduling with a time quantum of 4, what is the average waiting time?
Options
- 4.33
- 5.67
- 6.33
- 7.00
Show the answer and the worked solution
Correct answer: B. 5.67
Worked solution
- The Gantt chart is P1 from 0 to 4, P2 from 4 to 7, P3 from 7 to 10, then P1 again from 10 to 30.
- P1 finishes at 30 with a burst of 24, so it waits 30 − 24 = 6 units.
- P2 finishes at 7 with a burst of 3, so it waits 4 units; P3 finishes at 10 with a burst of 3, so it waits 7 units.
- The total is 6 + 4 + 7 = 17, so the average is 17 / 3 = 5.67 units.
Answer: 5.67.
The idea
Round robin trades average waiting time for responsiveness. A quantum far larger than every burst degenerates into FCFS, while a tiny quantum spends most of the CPU on context switches.
Shortcut. P2 and P3 finish in their first turn, so they wait 4 and 7; P1 waits only between its first slice and its return, 10 − 4 = 6. The total 17 ÷ 3 = 5.67.
Common trap. 7.00 takes P1's wait as 10, the time it resumes, without subtracting the 4 units it had already run: (10 + 4 + 7) ÷ 3 = 7.