Skip to main content

Non-preemptive SJF with P4 arriving

Short answer

Non-preemptive SJF selects shortest burst when CPU free. Schedule: P3(0-2), P4(2-6), P1(6-12), P2(12-20). Waiting times: P1=6ms, P2=12ms, P3=0ms, P4=1ms; average=4.75ms. Turnaround times: P1=12ms, P2=20ms, P3=2ms, P4=5ms; average=9.75ms.

Three processes with process IDs P1, P2, P3 with estimated completion times 6, 8, 2 milliseconds respectively enter the ready queue together (in the order P1, P2, P3). Process P4 with estimated execution completion time 4 milliseconds enters the ready queue after 1 millisecond. Calculate the waiting time and turn-around-time (TAT) for each process and the average waiting time and TAT in the non-preemptive shortest-job-first scheduling.

Non-preemptive SJF: when the CPU becomes free, the ready process with the shortest burst time is selected, and it runs until it finishes. Waiting time (WT) = start time - arrival time; turnaround time (TAT) = completion time - arrival time = WT + burst time.

ProcessArrival (ms)Burst (ms)
P106
P208
P302
P414

Schedule

  • t = 0: P1, P2, P3 are ready, the shortest is P3 (2 ms), so P3 runs from 0 to 2 (it cannot be interrupted when P4 arrives at t = 1).
  • t = 2: P1 (6), P2 (8), P4 (4) are ready, the shortest is P4: runs 2 to 6.
  • t = 6: P1 (6) then P2 (8): P1 runs 6 to 12.
  • t = 12: P2 runs 12 to 20.
 | P3 |   P4   |     P1     |        P2        |
 0    2        6            12                 20
ProcessCompletionTAT = CT - ATWT = TAT - Burst
P11212 - 0 = 1212 - 6 = 6
P22020 - 0 = 2020 - 8 = 12
P322 - 0 = 22 - 2 = 0
P466 - 1 = 55 - 4 = 1

Average WT = (6 + 12 + 0 + 1) / 4 = 19 / 4 = 4.75 ms Average TAT = (12 + 20 + 2 + 5) / 4 = 39 / 4 = 9.75 ms

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 6 questions →