Skip to main content

Scheduling algorithms with numerical

Short answer

FCFS services in arrival order (AWT 4.75 ms, ATAT 8.75 ms); SJF picks shortest job next (AWT 4, ATAT 8); SRTN preempts for shortest remaining time (AWT 3, ATAT 7); Round Robin (q=2 ms) slices time (AWT 5, ATAT 9); Priority schedules by static rank (AWT 5.5, ATAT 9.5); HRRN uses response ratio to limit starvation (AWT 4, ATAT 8).

Explain the FCFS, SJF, SRTN, Round Robin, Priority and HRRN scheduling algorithms with numerical examples.

Common data used for all examples (times in ms; priority 1 = highest, used only for the priority algorithm):

ProcessArrivalBurstPriority
P1073
P2241
P3414
P4542

Turnaround time = completion − arrival; waiting time = turnaround − burst.

1. FCFS

Processes are served in order of arrival; non-preemptive. Simple but suffers from the convoy effect.

| P1 | P2 | P3 | P4 |
0    7    11   12   16
ProcessArrivalBurstCompletionTurnaroundWaiting
P107770
P2241195
P3411287
P45416117

AWT = 19/4 = 4.75, ATAT = 35/4 = 8.75

2. SJF (non-preemptive)

At each completion the ready process with the smallest burst is chosen. It gives minimum average waiting time among non-preemptive algorithms but needs burst estimates and may starve long jobs.

| P1 | P3 | P2 | P4 |
0    7    8    12   16
ProcessArrivalBurstCompletionTurnaroundWaiting
P107770
P22412106
P341843
P45416117

AWT = 16/4 = 4, ATAT = 32/4 = 8

3. SRTN (SRTF, preemptive SJF)

The process with the shortest remaining time runs; a new arrival with less remaining time preempts the current one. At t=2 P2 (4) preempts P1 (5 left); at t=4 P3 (1) preempts P2 (2 left); P2 resumes at 5 and ends at 7, then P4 (4) runs, and P1 last.

| P1 | P2 | P3 | P2 | P4 | P1 |
0    2    4    5    7    11   16
ProcessArrivalBurstCompletionTurnaroundWaiting
P10716169
P224751
P341510
P4541162

AWT = 12/4 = 3, ATAT = 28/4 = 7

4. Round Robin (q = 2)

Each process runs for at most 2 ms and then goes to the tail of the ready queue; new arrivals join before the preempted process.

| P1 | P2 | P1 | P3 | P2 | P4 | P1 | P4 | P1 |
0    2    4    6    7    9    11   13   15   16
ProcessArrivalBurstCompletionTurnaroundWaiting
P10716169
P224973
P341732
P45415106

AWT = 20/4 = 5, ATAT = 36/4 = 9

5. Priority (non-preemptive)

The ready process with the highest priority (smallest number) is chosen at each completion. Low-priority P3 may starve (solved by aging).

| P1 | P2 | P4 | P3 |
0    7    11   15   16
ProcessArrivalBurstCompletionTurnaroundWaiting
P107770
P2241195
P341161211
P45415106

AWT = 22/4 = 5.5, ATAT = 38/4 = 9.5

6. HRRN (non-preemptive)

Response ratio = (waiting + burst)/burst. At t=7: P2 = (5+4)/4 = 2.25, P3 = (3+1)/1 = 4, P4 = (2+4)/4 = 1.5, so P3 runs; at t=8: P2 = 2.5, P4 = 1.75, so P2 runs. It limits starvation by aging.

| P1 | P3 | P2 | P4 |
0    7    8    12   16
ProcessArrivalBurstCompletionTurnaroundWaiting
P107770
P22412106
P341843
P45416117

AWT = 16/4 = 4, ATAT = 32/4 = 8

Comparison

AlgorithmAWTATAT
FCFS4.758.75
SJF (non-preemptive)48
SRTN (SRTF, preemptive SJF)37
Round Robin (q = 2)59
Priority (non-preemptive)5.59.5
HRRN (non-preemptive)48

Answer: SRTN gives the least AWT (3.0 ms) and ATAT (7.0 ms); FCFS 4.75 / 8.75; SJF and HRRN 4.0 / 8.0; RR 5.0 / 9.0; priority 5.5 / 9.5.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 2 questions →