Skip to content
We areTOP 1%

Numerical: compute waiting and turnaround times under SRTF and Round Robin.

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 bursts of 7, 4, 1 and 4. Find the average waiting and turnaround times under SRTF and Round Robin (quantum 2). Answer: SRTF 3 and 7; RR 5 and 9.

  • SRTF (Shortest Remaining Time First, preemptive SJF): when a process arrives, preempt the running process if the newcomer's burst is shorter than its remaining time.
  • RR: a process whose quantum expires joins the back of the queue, behind any process arriving at that same moment.

Example (worked solution):

SRTF: P1 0-2, P2 2-4, P3 4-5, P2 5-7, P4 7-11, P1 11-16
RR:   P1 0-2, P2 2-4, P1 4-6, P3 6-7, P2 7-9, P4 9-11, P1 11-13, P4 13-15, P1 15-16

In SRTF, P2 (4) preempts P1 (5 left) at time 2, P3 (1) preempts P2 (2 left) at time 4, and P2 (2 left) then beats P4 (4).

ProcessSRTF CT, TAT, WTRR CT, TAT, WT
P116, 16, 916, 16, 9
P27, 5, 19, 7, 3
P35, 1, 07, 3, 2
P411, 6, 215, 10, 6

Averages: SRTF TAT 28 / 4 = 7, WT 12 / 4 = 3; RR TAT 36 / 4 = 9, WT 20 / 4 = 5. RR trades average waiting time for fairness.

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