Skip to main content

FCFS, SJF, Priority, RR Gantt; max AWT

Short answer

FCFS yields the maximum average waiting time of 9.6 ms due to the convoy effect, while SJF gives the minimum at 2.6 ms. The Gantt charts are: FCFS P1-P2-P3-P4-P5; SJF P2-P4-P3-P5-P1; Priority P2-P5-P1-P3-P4; RR P1-P2-P3-P4-P5-P1.

Consider the following set of processes with the length of the CPU burst time given in millisecond.

ProcessP1P2P3P4P5
Burst time101212
Priority31342
Assume the processes arrived in the order P1, P2, P3, P4 and P5 all at time 0, priority 1 as highest and 4 as lowest.
a) Draw the Gantt chart for FCFS, SJF, Priority and Round Robin (Quantum = 2).
b) Which algorithm results in the maximum average waiting time?

Assumptions: all processes arrive at time 0 in the order P1 to P5; priority 1 is highest; for the priority algorithm, ties (P1 and P3 both priority 3) are broken by arrival order (FCFS); SJF is non-preemptive. Waiting time = turnaround − burst (arrival is 0, so turnaround = completion time).

a) Gantt charts

FCFS

| P1 | P2 | P3 | P4 | P5 |
0    10   11   13   14   16

SJF (order of burst: P2=1, P4=1, P3=2, P5=2, P1=10)

| P2 | P4 | P3 | P5 | P1 |
0    1    2    4    6    16

Priority (order: P2, P5, P1, P3, P4)

| P2 | P5 | P1 | P3 | P4 |
0    1    3    13   15   16

Round Robin, quantum = 2

| P1 | P2 | P3 | P4 | P5 | P1 |
0    2    3    5    6    8    16

Waiting and turnaround times

ProcessFCFS WTFCFS TATSJF WTSJF TATPriority WTPriority TATRR WTRR TAT
P1010616313616
P21011010123
P3111324131535
P4131412151656
P51416461368
Average9.612.82.65.86.49.64.47.6

Example (FCFS): waiting times are 0, 10, 11, 13, 14, so average = 48/5 = 9.6 ms.

b) Algorithm with the maximum average waiting time

AlgorithmAverage waiting time (ms)
FCFS9.6
SJF2.6
Priority6.4
Round Robin (q=2)4.4

Answer: FCFS gives the maximum average waiting time (9.6 ms), because the long process P1 (10 ms) is served first and all short jobs wait behind it (convoy effect). SJF gives the minimum (2.6 ms).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 2 questions →