- Asked 2/19
- 2076 Baisakh · 6 marks
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.
| Process | AT | BT | CT | TAT = CT - AT | WT = TAT - BT |
|---|---|---|---|---|---|
| P1 | 0 | 7 | 7 | 7 | 0 |
| P2 | 0 | 8 | 30 | 30 | 22 |
| P3 | 0 | 5 | 22 | 22 | 17 |
| P4 | 5 | 10 | 17 | 12 | 2 |
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)
Related questions
- Non-preemptive priority scheduling (10, 5, 7 ms) · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling with P4 (6 ms) · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling (4, 6, 5 ms) · Embedded System, chapter 6
- Priority and SJF scheduling with P4 and P5 · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling (4, 10, 5 ms) · Embedded System, chapter 6 · asked 2×
- Preemptive SJF/SRT scheduling (10, 5, 7 ms) · Embedded System, chapter 6
- Round robin scheduling (53, 17, 68, 24 ms) · Embedded System, chapter 6 · asked 4×
- Real-time scheduling; two-processor numerical · Operating System, chapter 2