Skip to main content

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:

ProcessArrival timeBurst timePriority
P1033
P2165
P3212
P4341
P5424
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
ProcessArrivalBurstCompletionTurnaroundWaiting
P103774
P21616159
P321421
P43415128
P5421175

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
ProcessArrivalBurstCompletionTurnaroundWaiting
P103885
P21616159
P321310
P434740
P5421064

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
ProcessArrivalBurstCompletionTurnaroundWaiting
P103330
P21616159
P321421
P4341073
P542620

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

Summary

AlgorithmAverage waiting timeAverage turnaround time
Round Robin (q=1)5.48.6
Priority preemptive3.66.8
Preemptive SJF2.65.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)

All Operating System chapter 2 questions →