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

# Preemptive priority scheduling (4, 10, 5 ms)

Embedded System · Chapter 6: RTOS

- Asked in: 2074 Bhadra, 6 marks
- Video: [Preemptive Priority Scheduling Algorithm | With Example | Operating System](https://www.youtube.com/watch?v=A860nFJ0FsA) — Start Practicing
- 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-4-10-5-p4
- Whole chapter: https://www.bctengineer.com/md/semester_6/embedded_system/chapter-6

## Question

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.

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

## Answer

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

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

## Check yourself

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

1. Why does P3 run from 4 to 5?
   A. P3 has the shortest burst
   B. P4 has not arrived and P2 is not allowed
   C. P1 finished and P3 (priority 2) outranks P2 (priority 3)
   D. P3 arrived last
   Answer: C. Priority, not burst, picks the process. (Key point: Who runs 4-5)

2. What happens to P3 at t = 5?
   A. P3 finishes first
   B. P4 (priority 0) pre-empts it, leaving 4 ms
   C. P3 is terminated
   D. P2 pre-empts P3
   Answer: B. P3 had run 1 ms of 5. (Key point: Preemption)

3. What is P2's waiting time?
   A. 12 ms
   B. 22 ms
   C. 10 ms
   D. 7 ms
   Answer: A. P2 completes at 22, WT = 22 - 10 = 12. (Key point: P2 waiting time)

4. What are AWT and ATAT?
   A. 10.25 ms and 4.75 ms
   B. 5.5 ms and 11 ms
   C. 19 ms and 41 ms
   D. 4.75 ms and 10.25 ms
   Answer: D. AWT = 19/4; ATAT = 41/4. (Key point: Averages)

## Close variants set in other exams

- [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×

## 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×
- [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×
- [Priority scheduling (7, 8, 5 ms) with P4](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-priority-7-8-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
- [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
- [Non-preemptive SJF with P4 arriving](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-sjf-nonpreemptive-6-8-2) — Embedded System, chapter 6, asked 2×

## Related in other subjects

- [Preemptive priority and SRTF Gantt](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apreemptive-priority-srtf-gantt) — Operating System, chapter 2
