- 2071 Magh · 2+8 marks
RR, preemptive priority, 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.
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 |
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)
| 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
| 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)
| 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.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- FCFS, SJF, Priority, RR Gantt; max AWT · Operating System, chapter 2
- Preemptive priority and SRTF Gantt · Operating System, chapter 2
- FCFS, SJF, RR Gantt and turnaround · Operating System, chapter 2
- Real-time scheduling; two-processor numerical · Operating System, chapter 2
- CPU criteria; RR Gantt and times · Operating System, chapter 2
- Two processors: priority and RR (q=3) · Operating System, chapter 2
- Priority and SJF scheduling with P4 and P5 · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling with P4 (6 ms) · Embedded System, chapter 6 · asked 2×
- Non-preemptive SJF with P4 arriving · Embedded System, chapter 6 · asked 2×
- Preemptive priority scheduling (4, 6, 5 ms) · Embedded System, chapter 6