Skip to main content

Priority scheduling (7, 8, 5 ms) with P4

Short answer

Order P1, P4, P3, P2 gives waiting times: P1=0, P2=22, P3=17, P4=2 ms. Average waiting time = 10.25 ms, average turnaround time = 17.75 ms.

Three processes with process IDs P1, P2, P3 with estimated completion time 7, 8, 5 ms and priorities 0, 3, 2 (0-highest, 3-lowest) respectively enter the ready queue together in order P1, P2, P3 (assume only P1 is present in the Ready queue when the scheduler picks it up and P2 and P3 enter ready queue after that). Now a process P4 with estimated completion time 10 ms and priority 1 enters the ready queue after 5 ms of execution of P1. Calculate waiting time and TAT for each process and average waiting time and TAT. Assume there is no I/O waiting for the process and priority-based scheduling.

The question does not say preemptive, and P1 is picked when alone; the standard reading is non-preemptive priority scheduling (0 = highest priority). P2 and P3 arrive just after 0, and P4 arrives at 5 ms, while P1 is still running.

Gantt chart

| P1 | P4 | P3 | P2 |
0    7    17   22   30

Trace

  • 0-7: P1 runs to completion. P4 (arrived at 5) must wait.
  • At 7, ready: P2 (priority 3), P3 (priority 2), P4 (priority 1). Order: P4, P3, P2.
  • 7-17: P4. 17-22: P3. 22-30: P2.

Calculation

TAT = completion time - arrival time; WT = TAT - burst time.

ProcessATBTCTTAT = CT - ATWT = TAT - BT
P107770
P208303022
P305222217
P451017122

AWT = (0 + 22 + 17 + 2) / 4 = 41/4 = 10.25 ms

ATAT = (7 + 30 + 22 + 12) / 4 = 71/4 = 17.75 ms

Answer: AWT = 10.25 ms, ATAT = 17.75 ms.

Note: the result is the same even if preemptive priority scheduling is intended. P4 (priority 1) arrives while P1 (priority 0, the highest) is running, so it cannot preempt P1, and the order P1, P4, P3, P2 does not change.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 6 questions →