Average waiting time under FCFS — Aptitude Question
Average waiting time under FCFS: 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: 105 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 first-come first-served scheduling, what is the average waiting time?
Options
- 13
- 17
- 20
- 27
Show the answer and the worked solution
Correct answer: B. 17
Worked solution
- FCFS runs the processes in arrival order: P1 from 0 to 24, P2 from 24 to 27, P3 from 27 to 30.
- Waiting time is start time minus arrival time, so P1 waits 0, P2 waits 24 and P3 waits 27.
- The total waiting time is 0 + 24 + 27 = 51.
- The average is 51 / 3 = 17 units.
Answer: 17.
The idea
FCFS is simple but suffers the convoy effect: one long process at the front inflates everybody else's wait. Running the same three in the order P2, P3, P1 would cut the average to 3.
Shortcut. Weight each burst by how many processes queue behind it: 24 × 2 + 3 × 1 + 3 × 0 = 51, and 51 ÷ 3 = 17.
Common trap. 27 is the average completion time, (24 + 27 + 30) ÷ 3, which is turnaround rather than waiting time.