Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Session 2.4: Scheduling criteria and non-preemptive scheduling: FCFS, SJF, Priority

How the scheduler is judged, how to draw Gantt charts and compute waiting and turnaround times, and how FCFS, SJF and Priority scheduling behave.

Module 2 2 hours Theory CO2
← Before
2.3 Threads
Multithreading models
You are here
2.4 Scheduling criteria and non-preemptive scheduling: FCFS, SJF, Priority
Module 2 · Process, Scheduling, Threads and Deadlocks
Next →
2.5 Scheduling II
RR, SRTF, MLQ, MLFQ

Learning objectives

By the end of this session you should be able to:

  • Describe the CPU–I/O burst cycle and when the scheduler is invoked.
  • Distinguish preemptive from non-preemptive scheduling and explain the dispatcher.
  • Define utilisation, throughput, turnaround, waiting and response time and compute them.
  • Solve FCFS, SJF and non-preemptive Priority problems with Gantt charts.
  • Predict burst lengths with exponential averaging and explain starvation and aging.

Lecture notes

1. The CPU–I/O burst cycle

Process execution alternates between CPU bursts (computing) and I/O bursts (waiting for a device). Measured burst lengths follow a curve with many short CPU bursts and a few long ones: I/O-bound programs have many short bursts, CPU-bound programs a few long ones. Scheduling exists to fill the CPU whenever the running process starts an I/O burst.

CPU burstI/O waitCPU burstI/O waitCPU burst→exit

2. When does the scheduler run? Preemptive vs non-preemptive

The short-term scheduler must choose a new process when the running process:

  1. switches from running to waiting (I/O request, wait()),
  2. switches from running to ready (timer interrupt),
  3. switches from waiting to ready (I/O completes),
  4. terminates.

If scheduling happens only in cases 1 and 4, it is non-preemptive (cooperative): once a process has the CPU it keeps it until it blocks or exits. Otherwise it is preemptive: the OS can take the CPU away. Preemption gives better response time but means a process can be interrupted while updating shared data — another reason for Module 3.

The dispatcher gives control to the chosen process: context switch, switch to user mode, jump to the right instruction. The time it takes is the dispatch latency.

3. Scheduling criteria and formulas

CPU utilisation ↑

Keep the CPU as busy as possible (40% lightly loaded – 90% heavily loaded).

Throughput ↑

Number of processes completed per time unit.

Turnaround time ↓

Submission to completion: TAT = CT − AT.

Waiting time ↓

Time spent in the ready queue: WT = TAT − BT.

Response time ↓

Submission to first run: RT = first start − AT.

Vocabulary used in every problem

AT arrival time · BT burst time · CT completion time · TAT turnaround · WT waiting · RT response. A Gantt chart is a bar showing which process runs in each time interval. Always draw it first, then fill the table.

4. First-Come, First-Served (FCFS)

The process that requests the CPU first gets it first — a simple FIFO queue. Non-preemptive.

Worked example — order matters

P1 = 24, P2 = 3, P3 = 3 ms, all arriving at time 0.

Order P1, P2, P3: Gantt P1 [0–24] P2 [24–27] P3 [27–30]. WT = 0, 24, 27 → average 17 ms.

Order P2, P3, P1: Gantt P2 [0–3] P3 [3–6] P1 [6–30]. WT = 6, 0, 3 → average 3 ms. Same work, six times less waiting.

Convoy effect: short processes stuck behind one long CPU-bound process — like cars behind a truck. FCFS is simple and fair in arrival order but gives poor average waiting time and is bad for time-sharing.

Simulator — FCFSEdit the inputs, press Run, then Step or Play.

5. Shortest-Job-First (SJF)

Give the CPU to the process with the smallest next CPU burst (FCFS breaks ties). SJF is provably optimal: it gives the minimum average waiting time for a given set of processes, because moving a short job before a long one reduces the short job's wait by more than it increases the long job's wait.

Worked example — SJF (non-preemptive)

P1 = 6, P2 = 8, P3 = 7, P4 = 3, all at time 0.

Order by burst: P4 [0–3] · P1 [3–9] · P3 [9–16] · P2 [16–24].

WT: P1 = 3, P2 = 16, P3 = 9, P4 = 0 → average 7 ms (FCFS in order P1..P4 would give 10.25 ms).

Simulator — SJFEdit the inputs, press Run, then Step or Play.

The catch: predicting the next burst

The scheduler cannot know the length of the next CPU burst. It predicts it with an exponential average of previous bursts:

\[ \tau_{n+1} = \alpha\, t_n + (1-\alpha)\, \tau_n, \qquad 0 \le \alpha \le 1 \]

where tn is the actual length of the n-th burst and τn the previous prediction. With α = 0.5, τ0 = 10 and actual bursts 6, 4, 6, 4: τ1 = 8, τ2 = 6, τ3 = 6, τ4 = 5. α = 0 ignores history's latest value; α = 1 uses only the last burst.

6. Priority scheduling

Each process has a priority number; the CPU goes to the highest priority (in this course, smaller number = higher priority). SJF is a special case where priority = predicted burst. Priorities can be internal (memory needs, I/O ratio) or external (importance, payment).

Worked example — non-preemptive priority

(burst, priority): P1 (10, 3), P2 (1, 1), P3 (2, 4), P4 (1, 5), P5 (5, 2), all at time 0.

Gantt: P2 [0–1] · P5 [1–6] · P1 [6–16] · P3 [16–18] · P4 [18–19].

WT: P1 = 6, P2 = 0, P3 = 16, P4 = 18, P5 = 1 → average 8.2 ms.

Simulator — Priority (non-preemptive)Edit the inputs, press Run, then Step or Play.
Starvation and aging

Problem: a low-priority process may wait forever while higher-priority ones keep arriving (indefinite blocking or starvation). Solution — aging: gradually raise the priority of processes that wait a long time, e.g. improve priority by 1 every 15 minutes, so eventually every process runs.

7. Non-preemptive algorithms compared

AlgorithmPicksStrengthWeakness
FCFSEarliest arrivalSimple, no starvationConvoy effect, high average WT
SJFShortest next burstOptimal average WTBurst must be predicted; long jobs may starve
PriorityHighest priorityExpresses importanceStarvation (fix with aging)

VideoBytes

Scheduling criteria and formulas

Video coming soon

Scheduling criteria and formulas

Recorded by Dr. Krithika L.B. Slot m2-sched-criteria

FCFS, SJF and Priority — worked examples

Video coming soon

FCFS, SJF and Priority — worked examples

Recorded by Dr. Krithika L.B. Slot m2-fcfs-sjf-priority

Interactive lessons

Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.

Lab connection

Check your understanding

Answer each question in your own words first, then reveal the model answer.

Revealed 0
P1 = 8, P2 = 4, P3 = 2 arrive at 0 in that order. Average WT under FCFS and SJF?

FCFS: WT 0, 8, 12 → 6.67. SJF order P3, P2, P1: WT P3 = 0, P2 = 2, P1 = 6 → 2.67.

Why is SJF hard to implement for the short-term scheduler?

The length of the next CPU burst is not known in advance; it has to be predicted, e.g. by exponential averaging of past bursts.

With α = 0.5, τn = 12 and tn = 4, what is τn+1?

0.5 × 4 + 0.5 × 12 = 8.

What is the convoy effect?

In FCFS, many short processes wait behind one long CPU-bound process, lowering CPU and device utilisation.

How does aging prevent starvation?

It increases the priority of a process the longer it waits, so eventually it reaches the top priority and runs.

Key takeaways

  • Scheduling decisions happen on block, preempt, wake-up and exit; non-preemptive uses only block and exit.
  • TAT = CT − AT, WT = TAT − BT, RT = first run − AT. Draw the Gantt chart first.
  • FCFS: simple, convoy effect. SJF: optimal average WT, needs burst prediction. Priority: starvation, fixed by aging.

Where this leads

All three algorithms let a process keep the CPU until it blocks. For interactive systems we must be able to take the CPU away. Next: preemptive and multilevel scheduling.

Continue to 2.5 — Round Robin, SRTF, preemptive priority, MLQ and MLFQ →