---
title: "Priority scheduling (7, 8, 5 ms) with P4"
subject: "Embedded System"
chapter: 6
key: "semester_6/embedded_system:sched-priority-7-8-5-p4"
source: https://www.bctengineer.com/q/semester_6/embedded_system/sched-priority-7-8-5-p4
site: BCT Engineering
---

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

Embedded System · Chapter 6: RTOS

- Asked in: 2076 Baisakh, 6 marks
- Video: [Preemptive Priority Scheduling Algorithm|| Operating System  | OS](https://www.youtube.com/watch?v=wldjV-wVvhg) — Sudhakar Atchala
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/embedded_system/sched-priority-7-8-5-p4
- Whole chapter: https://www.bctengineer.com/md/semester_6/embedded_system/chapter-6

## Question

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.

## 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.

## Answer

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

```text
| 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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Order after P1 finishes at 7?
   A. P2, P3, P4
   B. P4, P3, P2
   C. P3, P4, P2
   D. P4, P2, P3
   Answer: B. Priorities: P4 = 1, P3 = 2, P2 = 3. (Key point: Order after P1)

2. What is P4's waiting time?
   A. 2 ms
   B. 7 ms
   C. 10 ms
   D. 0 ms
   Answer: A. TAT = 17 - 5 = 12, WT = 12 - 10 = 2. (Key point: P4 waiting)

3. AWT and ATAT?
   A. 17.75 ms and 10.25 ms
   B. 11.5 ms and 18 ms
   C. 41 ms and 71 ms
   D. 10.25 ms and 17.75 ms
   Answer: D. AWT = 41/4; ATAT = 71/4. (Key point: Averages)

## Close variants set in other exams

- [Non-preemptive priority scheduling (10, 5, 7 ms)](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-priority-nonpreemptive-10-5-7) — Embedded System, chapter 6, asked 2×

## Related in Embedded System

- [Preemptive priority scheduling with P4 (6 ms)](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-priority-10-5-7-p4) — Embedded System, chapter 6, asked 2×
- [Preemptive priority scheduling (4, 6, 5 ms)](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-priority-4-6-5) — Embedded System, chapter 6
- [Priority and SJF scheduling with P4 and P5](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-priority-and-sjf-5-process) — Embedded System, chapter 6, asked 2×
- [Preemptive priority scheduling (4, 10, 5 ms)](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-priority-4-10-5-p4) — Embedded System, chapter 6, asked 2×
- [Preemptive SJF/SRT scheduling (10, 5, 7 ms)](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-srt-10-5-7) — Embedded System, chapter 6
- [Round robin scheduling (53, 17, 68, 24 ms)](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-rr-53-17-68-24-q4) — Embedded System, chapter 6, asked 4×

## Related in other subjects

- [Real-time scheduling; two-processor numerical](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Arealtime-two-processor-fcfs-sjf-priority-rr) — Operating System, chapter 2
