---
title: "RR, preemptive priority, preemptive SJF"
subject: "Operating System"
chapter: 2
key: "semester_6/operating_system:process-rr-priority-preemptive-sjf"
source: https://www.bctengineer.com/q/semester_6/operating_system/process-rr-priority-preemptive-sjf
site: BCT Engineering
---

# RR, preemptive priority, preemptive SJF

Operating System · Chapter 2: Process Management

- Asked in: 2071 Magh, 2+8 marks
- Video: [L-2.8: Pre-emptive Priority  Scheduling Algorithm with  Example | Operating System](https://www.youtube.com/watch?v=rsDGfFxSgiY) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/process-rr-priority-preemptive-sjf
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-2

## Question

What is process? From the given following information:
| Process | Arrival time | Burst time | Priority |
|---|---|---|---|
| P1 | 0 | 3 | 3 |
| P2 | 1 | 6 | 5 |
| P3 | 2 | 1 | 2 |
| P4 | 3 | 4 | 1 |
| P5 | 4 | 2 | 4 |
a) Draw the Gantt chart.
b) Calculate average waiting time and average turn around time for the following scheduling algorithm: i) Round Robin (q = 1) ii) Priority Preemptive iii) Preemptive SJF

## Short answer

A process is a program in execution. For Round Robin (q=1), AWT=5.4, ATAT=8.6; for Priority Preemptive, AWT=3.6, ATAT=6.8; for Preemptive SJF, AWT=2.6, ATAT=5.8. Preemptive SJF yields the smallest averages.

## Answer

A **process** is a program in execution. It is an active entity with its own program counter, registers, stack, data and address space, while a program is a passive file on disk.

Assumptions: a lower priority number means higher priority; waiting time = turnaround − burst; turnaround = completion − arrival. In round robin, a process arriving at the same instant a quantum ends joins the ready queue before the preempted process. Ties are broken by earlier arrival.

#### a, b) Gantt charts and times

**i) Round Robin (q = 1)**

```text
| P1 | P2 | P1 | P3 | P2 | P4 | P1 | P5 | P2 | P4 |
0    1    2    3    4    5    6    7    8    9    10
| P5 | P2 | P4 | P2 | P4 | P2 |
10   11   12   13   14   15   16
```

| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 0 | 3 | 7 | 7 | 4 |
| P2 | 1 | 6 | 16 | 15 | 9 |
| P3 | 2 | 1 | 4 | 2 | 1 |
| P4 | 3 | 4 | 15 | 12 | 8 |
| P5 | 4 | 2 | 11 | 7 | 5 |

Average waiting time = 27/5 = **5.4**; average turnaround time = 43/5 = **8.6**

**ii) Priority preemptive**

```text
| P1 | P3 | P4 | P1 | P5 | P2 |
0    2    3    7    8    10   16
```

| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 0 | 3 | 8 | 8 | 5 |
| P2 | 1 | 6 | 16 | 15 | 9 |
| P3 | 2 | 1 | 3 | 1 | 0 |
| P4 | 3 | 4 | 7 | 4 | 0 |
| P5 | 4 | 2 | 10 | 6 | 4 |

Average waiting time = 18/5 = **3.6**; average turnaround time = 34/5 = **6.8**

**iii) Preemptive SJF (SRTF)**

```text
| P1 | P3 | P5 | P4 | P2 |
0    3    4    6    10   16
```

| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 0 | 3 | 3 | 3 | 0 |
| P2 | 1 | 6 | 16 | 15 | 9 |
| P3 | 2 | 1 | 4 | 2 | 1 |
| P4 | 3 | 4 | 10 | 7 | 3 |
| P5 | 4 | 2 | 6 | 2 | 0 |

Average waiting time = 13/5 = **2.6**; average turnaround time = 29/5 = **5.8**


#### Summary

| Algorithm | Average waiting time | Average turnaround time |
|---|---|---|
| Round Robin (q=1) | 5.4 | 8.6 |
| Priority preemptive | 3.6 | 6.8 |
| Preemptive SJF | 2.6 | 5.8 |

**Answer:** preemptive SJF gives the smallest averages (AWT 2.6, ATAT 5.8 time units); priority preemptive gives AWT 3.6 and ATAT 6.8; round robin gives AWT 5.4 and ATAT 8.6.

## Check yourself

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

1. How does a process differ from a program?
   A. A process is a passive file on disk; a program is active
   B. A process is a program in execution (active entity); a program is a passive file
   C. They are identical
   D. A process has no program counter
   Answer: B. A process has its own program counter, registers, stack and address space while executing; a program is just a file. (Key point: Process definition)

2. What are AWT and ATAT for priority preemptive scheduling in this problem?
   A. AWT 2.6, ATAT 5.8
   B. AWT 5.4, ATAT 8.6
   C. AWT 3.6, ATAT 6.8
   D. AWT 4.0, ATAT 7.0
   Answer: C. Waiting times 5, 9, 0, 0, 4 sum to 18 (3.6) and turnaround times sum to 34 (6.8). (Key point: Priority preemptive averages)

3. Which of the three algorithms gives the smallest averages, and why?
   A. Round robin, because it is fair
   B. Priority preemptive, because P4 has priority 1
   C. Preemptive SJF, because it always runs the shortest remaining job
   D. All are equal
   Answer: C. Preemptive SJF (SRTF) gives AWT 2.6 and ATAT 5.8, the smallest, since short jobs finish early. (Key point: Best algorithm)

## Related in Operating System

- [FCFS, SJF, Priority, RR Gantt; max AWT](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Ascheduling-gantt-fcfs-sjf-priority-rr-q2) — Operating System, chapter 2
- [Preemptive priority and SRTF Gantt](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apreemptive-priority-srtf-gantt) — Operating System, chapter 2
- [FCFS, SJF, RR Gantt and turnaround](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afcfs-sjf-rr-q5-timeline) — 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
- [CPU criteria; RR Gantt and times](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Acpu-criteria-rr-gantt) — Operating System, chapter 2
- [Two processors: priority and RR (q=3)](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Atwo-processor-priority-rr-q3) — Operating System, chapter 2

## Related in other subjects

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