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

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

Embedded System · Chapter 6: RTOS

- Asked in: 2079 Asoj, 6 marks
- Video: [Shortest Remaining Time First Scheduling Algorithm || SRTF || Preemptive || Operating Systems || OS](https://www.youtube.com/watch?v=Tcuyr91Y_Ro) — 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-srt-10-5-7
- 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 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.

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

## Answer

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

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

| Process | AT | BT | CT | TAT = CT - AT | WT = TAT - BT |
|---|---|---|---|---|---|
| P1 | 0 | 10 | 24 | 24 | 14 |
| P2 | 0 | 5 | 7 | 7 | 2 |
| P3 | 0 | 7 | 14 | 14 | 7 |
| P4 | 2 | 2 | 4 | 2 | 0 |

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

## Check yourself

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

1. What rule does preemptive SJF/SRT follow at an arrival?
   A. Always finish running process
   B. Use priorities
   C. Compare the new burst with the remaining time of the running process and run the smaller
   D. Use time slices
   Answer: C. The smallest remaining time runs. (Key point: SRT rule)

2. Why does P4 pre-empt P2 at 2 ms?
   A. P4 has higher priority
   B. P4 needs 2 ms, P2 has 3 ms left
   C. P2 blocked
   D. P4 arrived first
   Answer: B. 2 < 3. (Key point: Preemption at 2)

3. Execution order?
   A. P2, P4, P2, P3, P1
   B. P2, P3, P4, P1
   C. P1, P2, P3, P4
   D. P4, P2, P3, P1
   Answer: A. After P2 completes at 7, P3 (7) then P1 (10). (Key point: Order)

4. AWT and ATAT?
   A. 11.75 ms and 5.75 ms
   B. 5 ms and 10 ms
   C. 23 ms and 47 ms
   D. 5.75 ms and 11.75 ms
   Answer: D. AWT = 23/4; ATAT = 47/4. (Key point: Averages)

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

## Related in other subjects

- [RR, preemptive priority, preemptive SJF](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aprocess-rr-priority-preemptive-sjf) — Operating System, chapter 2
- [Avg turnaround: FCFS, RR, SJF, SRT, HRRN](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aavg-turnaround-fcfs-rr-sjf-srt-hrrn) — Operating System, chapter 2
- [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
