Skip to main content

Preemptive priority scheduling with P4 (6 ms)

Short answer

Preemptive priority (0 highest). Schedule: P1(0-5), P4(5-11), P1(11-16), P3(16-23), P2(23-28). Waiting times: P1=6ms, P2=23ms, P3=16ms, P4=0ms; average=11.25ms. Turnaround times: P1=16ms, P2=28ms, P3=23ms, P4=6ms; average=18.25ms.

In priority based (preemptive) scheduling, three processes IDs P1, P2, P3 with estimated completion time 10, 5, 7 msec. and priorities 1, 3, 2 (0-highest and 3-lowest priority) respectively enter the ready queue together. A new process P4 with estimated completion time 6 ms and priority 0 enters the ready queue after 5 ms of start of execution of P1. Calculate the waiting time and turn around time for each process and the average waiting time and average TAT. Assume all the processes contain only CPU operation and no I/O operations are involved.

Preemptive priority scheduling (0 = highest priority): the CPU always runs the highest-priority ready process; a newly arrived higher-priority process pre-empts the running one. WT = TAT - burst; TAT = completion - arrival.

ProcessArrivalBurstPriority
P10101
P2053
P3072
P4560

Schedule

  • 0 to 5: P1 (priority 1, best of P1/P2/P3) runs; 5 ms remain.
  • t = 5: P4 (priority 0) arrives and pre-empts P1. P4 runs 5 to 11.
  • 11 to 16: P1 resumes, finishes its remaining 5 ms (priority 1).
  • 16 to 23: P3 (priority 2) runs 7 ms.
  • 23 to 28: P2 (priority 3) runs 5 ms.
 |   P1   |    P4    |   P1   |     P3     |   P2   |
 0        5          11       16           23       28
ProcessCompletionTATWT
P11616 - 0 = 1616 - 10 = 6
P22828 - 0 = 2828 - 5 = 23
P32323 - 0 = 2323 - 7 = 16
P41111 - 5 = 66 - 6 = 0

Average WT = (6 + 23 + 16 + 0) / 4 = 45 / 4 = 11.25 ms Average TAT = (16 + 28 + 23 + 6) / 4 = 73 / 4 = 18.25 ms

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 6 questions →