- Asked 2/19
- 2074 Bhadra · 6 marks
Preemptive priority scheduling (4, 10, 5 ms)
Short answer
Execution order P1, P3, P4, P3, P2 results in waiting times P1=0, P2=12, P3=7, P4=0 ms. Average waiting time = 4.75 ms, average turnaround time = 10.25 ms.
Three processes P1, P2 and P3 with estimated completion time 4, 10, 5 ms and priorities 1, 3, 2 respectively enter the ready queue together. A new process P4 with estimated completion time 3 ms and priority 0 enters the ready queue after 5 ms of start of operation. Calculate WT, TAT for each process and calculate AWT and ATAT using preemptive priority based scheduling algorithms.
In preemptive priority scheduling the CPU always runs the ready process with the highest priority; a newly arrived higher-priority process preempts the running one. Lower priority number means higher priority. Assumed: P1, P2, P3 arrive at 0; P4 arrives at 5 ms.
Gantt chart
| P1 | P3 | P4 | P3 | P2 |
0 4 5 8 12 22
Trace
- 0-4: P1 (priority 1) is the highest among P1, P2, P3 and finishes at 4.
- 4-5: P3 (priority 2) runs; P2 has priority 3.
- 5: P4 (priority 0) arrives and preempts P3, which has 4 ms left.
- 5-8: P4 runs to completion.
- 8-12: P3 resumes and finishes.
- 12-22: P2 runs last.
Calculation
TAT = completion time - arrival time; WT = TAT - burst time.
| Process | AT | BT | CT | TAT = CT - AT | WT = TAT - BT |
|---|---|---|---|---|---|
| P1 | 0 | 4 | 4 | 4 | 0 |
| P2 | 0 | 10 | 22 | 22 | 12 |
| P3 | 0 | 5 | 12 | 12 | 7 |
| P4 | 5 | 3 | 8 | 3 | 0 |
AWT = (0 + 12 + 7 + 0) / 4 = 19/4 = 4.75 ms
ATAT = (4 + 22 + 12 + 3) / 4 = 41/4 = 10.25 ms
Answer: AWT = 4.75 ms, ATAT = 10.25 ms.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Priority and SJF scheduling with P4 and P5 · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling with P4 (6 ms) · Embedded System, chapter 6 · asked 2×
- Non-preemptive priority scheduling (10, 5, 7 ms) · Embedded System, chapter 6 · asked 2×
- Priority scheduling (7, 8, 5 ms) with P4 · Embedded System, chapter 6 · asked 2×
- Preemptive SJF/SRT scheduling (10, 5, 7 ms) · Embedded System, chapter 6
- Preemptive priority scheduling (4, 6, 5 ms) · Embedded System, chapter 6
- Non-preemptive SJF with P4 arriving · Embedded System, chapter 6 · asked 2×
- Preemptive priority and SRTF Gantt · Operating System, chapter 2