CPU Scheduling

Answer & solution
Official answer: D
Step through it (7 steps)
Track remaining time at each arrival rather than comparing original burst times throughout. At t=0 only P1 is available. At t=1 P1 has 9 ms left, less than P2's 13, so P1 continues. At t=2 P1 has 8 ms left and P3 arrives needing 6; P3 preempts it and runs from 2 to 8.
At t=8 P3 completes and P4 arrives. Remaining times are P1:8, P2:13, P4:9, so choose P1 for 8…16. Next choose P4 for 16…25, followed by P2 for 25…38. The execution intervals are therefore P1 [0,2), P3 [2,8), P1 [8,16), P4 [16,25), P2 [25,38).
Turnaround equals completion minus arrival: P1=16−0=16, P2=38−1=37, P3=8−2=6, P4=25−8=17 ms. Their sum is 76 ms and the average is 76/4=19 ms. Waiting time would subtract each burst as well; that is not the requested metric. Answer: D.







