Skip to main content

Non-preemptive priority scheduling (10, 5, 7 ms)

Short answer

Non-preemptive priority gives order P1, P4, P2, P3. Waiting times: P1=0, P2=16, P3=21, P4=4 ms. Average waiting time = 10.25 ms, average turnaround time = 17.25 ms.

Three processes with process IDs P1, P2, P3 with estimated completion time 10, 5, 7 ms and priorities 0, 2, 3 (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 & P3 enter ready queue after that). Now a process P4 with estimated completion time 6 ms and priority 1 enters the ready queue after 6 ms of execution of P1. Calculate waiting time and TAT for each process and average waiting time and average TAT. Assume there is no I/O waiting for the processes and priority-based non-preemptive scheduling.

In non-preemptive priority scheduling a running process is never interrupted; when it ends, the ready process with the highest priority (lowest number) is chosen. P1 is alone when picked, so it starts at 0 and P2, P3 join the queue just after. P4 arrives at 6 ms (6 ms into P1).

Gantt chart

| P1 | P4 | P2 | P3 |
0    10   16   21   28

Trace

  • 0-10: P1 runs to completion (no preemption, although P4 arrives at 6).
  • At 10 the ready queue holds P2 (priority 2), P3 (priority 3), P4 (priority 1). P4 is chosen: 10-16.
  • 16-21: P2 (priority 2). 21-28: P3 (priority 3).

Calculation

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

ProcessATBTCTTAT = CT - ATWT = TAT - BT
P101010100
P205212116
P307282821
P46616104

AWT = (0 + 16 + 21 + 4) / 4 = 41/4 = 10.25 ms

ATAT = (10 + 21 + 28 + 10) / 4 = 69/4 = 17.25 ms

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

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 6 questions →