Three processes with burst times 24, 3 and 3 arrive together. What is the average waiting time under FCFS?
Run in arrival order P1, P2, P3. Waiting times are 0, 24 and 27, so the average is (0 + 24 + 27) / 3 = 17 ms. Waiting time is the time a process spends in the ready queue before it gets the CPU.
Explain it simply
FCFS (first come, first served) is a queue at a chai stall: whoever came first is served first, and nobody can jump ahead. A process keeps the CPU until it finishes.
Since all three arrive at time 0, the order is P1, P2, P3. Waiting time = start time - arrival time.
Example
Gantt chart:
| P1 (24) | P2 (3) | P3 (3) |
0 24 27 30| Process | Burst | Start | Waiting |
|---|---|---|---|
| P1 | 24 | 0 | 0 |
| P2 | 3 | 24 | 24 |
| P3 | 3 | 27 | 27 |
Average waiting time = (0 + 24 + 27) / 3 = 51 / 3 = 17 ms.
Average turnaround time = (24 + 27 + 30) / 3 = 81 / 3 = 27 ms.
The two short jobs are stuck behind the long one. If the order were P2, P3, P1, the average waiting time would drop to (0 + 3 + 6) / 3 = 3 ms. Same work, very different waiting.
What to say in the interview
"Under FCFS the Gantt chart is P1 to 24, P2 to 27, P3 to 30. Waiting times are 0, 24 and 27, average 17 ms. I'd also point out that arrival order matters a lot: put the short jobs first and the average falls to 3 ms."
Common mistakes
- Dividing by the total burst time (30) instead of the number of processes.
- Using completion time as waiting time.