Skip to main content

Preemptive SJF/SRT scheduling (10, 5, 7 ms)

Short answer

Using SRT scheduling, execution is P2, P4, P2, P3, P1. Waiting times: P1=14, P2=2, P3=7, P4=0 ms. Average waiting time = 5.75 ms, average turnaround time = 11.75 ms.

Three processes with process IDs P1, P2, P3 with estimated completion time 10, 5, 7 ms respectively enter the ready queue together. A new process P4 with estimated completion time 2 ms enters the ready queue after 2 ms. 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 preemptive SJF / SRT scheduling.

Preemptive SJF (shortest remaining time first, SRT): at every arrival the scheduler compares the new burst with the remaining time of the running process and runs the smaller. P1, P2, P3 arrive at 0 and P4 at 2 ms.

Gantt chart

| P2 | P4 | P2 | P3 | P1 |
0    2    4    7    14   24

Trace

  • 0-2: P2 (5 ms) is shortest and runs.
  • 2: P4 (2 ms) arrives; P2 has 3 ms left, so P4 preempts.
  • 2-4: P4 finishes. 4-7: P2 finishes its remaining 3 ms.
  • 7-14: P3 (7 ms). 14-24: P1 (10 ms).

Calculation

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

ProcessATBTCTTAT = CT - ATWT = TAT - BT
P1010242414
P205772
P30714147
P422420

AWT = (14 + 2 + 7 + 0) / 4 = 23/4 = 5.75 ms

ATAT = (24 + 7 + 14 + 2) / 4 = 47/4 = 11.75 ms

Answer: AWT = 5.75 ms, ATAT = 11.75 ms.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 6 questions →