Skip to article
ContentsSRTF
Learn/Chapter 03 of 08

SRTF Scheduling: Shortest Remaining Time First

Shortest Remaining Time First (SRTF) runs the eligible process with the least CPU work still unfinished. It is preemptive: a new arrival can interrupt the current process when the newcomer needs strictly less work than the current process has left.

The rule

Remaining work is the original burst minus service already received. Comparing the original bursts after a process has run would apply the wrong rule. In this simulator, an equal remaining value does not force the running process to yield.

Worked example

Example inputs
ProcessArrivalBurst
P107
P213
P321
Scroll horizontally for all columns

One CPU · One burst per process · No I/O · Dispatch cost 0. Times are abstract units.

At 1, P2 needs 3 units, strictly less than P1's 6 remaining. It interrupts the incumbent; unfinished work is retained.

At 2, P3 needs 1 units, strictly less than P2's 2 remaining. It interrupts the incumbent; unfinished work is retained.

The full CPU trace is P1 [0, 1), P2 [1, 2), P3 [2, 3), P2 [3, 5), P1 [5, 11).

Worked trace SRTF
At t = 1P2: 3 < P1: 6

Strictly shorter remaining work takes the CPU.

At t = 2P3: 1 < P2: 2

Strictly shorter remaining work takes the CPU.

CPU execution: SRTFP1 runs [0, 1); P2 runs [1, 2); P3 runs [2, 3); P2 runs [3, 5); P1 runs [5, 11). Segment widths show elapsed time. Diamond markers show arrivals. P1 waits 4 units after its first startARRIVALSP1P2P3P1P2P3P2P10123511P1 waits 4 units after its first start
Scroll horizontally for all intervals
Complete CPU trace · [start, end)
  1. P1: [0, 1)
  2. P2: [1, 2)
  3. P3: [2, 3)
  4. P2: [3, 5)
  5. P1: [5, 11)
Each interruption follows a strictly shorter remaining service requirement. Interrupted work is retained.
Open this example in the simulator

Calculate the result

Per-process results
ProcessCompletionWaitingTurnaroundResponse
P1114110
P25140
P33010
Scroll horizontally for all columns

P1: turnaround = 11 − 0 = 11. Waiting = 11 − 7 = 4. First response = 0 − 0 = 0.

First response measures only the first service. Waiting also includes later periods when this process is ready but another process owns the CPU.

Mean waiting = (4 + 1 + 0) / 3 ≈ 1.667 units. Mean response = 0 units.

The tradeoff

SRTF gives short remaining work quick access, but long work can be delayed by later short arrivals. It also needs known or estimated service lengths. More process changes can add overhead when dispatch cost is nonzero; the zero-cost example isolates the selection rule.