Consider the following processes, with the arrival time and the length of the CPU burst given in milliseconds. The scheduling algorithm used is preemptive shortest remaining-time first.
Process | Arrival Time | Burst Time P1 | 0 | 10 P2 | 3 | 6 P3 | 7 | 1 P4 | 8 | 3
The average turn around time of these processes is ____ milliseconds.
Explanation
Trace: [0-3] P1 runs alone (rem 10→7). At t=3, P2(rem6) arrives; P2<P1's remaining 7, so switch to P2. [3-7] P2 runs (rem 6→2). At t=7, P3(rem1) arrives — shortest of all, switch to P3. [7-8] P3 runs to completion (finishes at 8, turnaround=8-7=1). At t=8, P4(rem3) arrives; remaining candidates P1=7,P2=2,P4=3 — P2 shortest, resume P2. [8-10] P2 finishes (turnaround=10-3=7). At t=10, candidates P1=7,P4=3 — P4 shorter. [10-13] P4 finishes (turnaround=13-8=5). Only P1 left (rem7). [13-20] P1 finishes (turnaround=20-0=20). Average = (20+7+1+5)/4 = 33/4 = 8.25 ms.
Source: GATE CS 2016 (Session 2 / Set B) (2016)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.