Skip to content
We areTOP 1%

Numerical: compute average waiting and turnaround times under FCFS and SJF.

HardConceptOS Numericals
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

Problem: P1, P2, P3 and P4 arrive at times 0, 2, 4 and 5 with CPU bursts of 7, 4, 1 and 4. Find the average waiting and turnaround times under FCFS and non-preemptive SJF. Answer: FCFS 4.75 and 8.75; SJF 4 and 8.

  • Draw the Gantt chart, then use TAT = CT − AT (completion minus arrival) and WT = TAT − BT (turnaround minus burst).
  • In non-preemptive SJF, choose only among processes that have already arrived when the CPU becomes free; break ties by arrival time.
  • Check: the CPU never idles here, so the last completion time equals the total burst, 7 + 4 + 1 + 4 = 16.

Example (worked solution):

FCFS: P1 0-7, P2 7-11, P3 11-12, P4 12-16
SJF:  P1 0-7, P3 7-8,  P2 8-12,  P4 12-16

At time 7, SJF picks P3 (burst 1); P2 then beats P4 (both 4) because it arrived first.

ProcessFCFS CT, TAT, WTSJF CT, TAT, WT
P17, 7, 07, 7, 0
P211, 9, 512, 10, 6
P312, 8, 78, 4, 3
P416, 11, 716, 11, 7

Averages: FCFS TAT 35 / 4 = 8.75, WT 19 / 4 = 4.75; SJF TAT 32 / 4 = 8, WT 16 / 4 = 4.

More in OS Numericals

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account