CPU Scheduling

first-come, first-served scheduling

/ FCFS /

This is the fairness of an ordinary queue at a bank: whoever gets in line first is served first, all the way through, no jumping ahead. First-come, first-served (FCFS) scheduling does exactly this for processes — the ready queue is a simple FIFO list, and the CPU is given to processes strictly in the order they became ready.

How it works: when a process becomes ready it joins the tail of the queue; the scheduler always picks the process at the head and lets it run to the end of its CPU burst before moving on. FCFS is non-preemptive — once a process starts, it keeps the CPU until it blocks or finishes. It is the simplest scheduler imaginable: trivial to implement, and obviously free of starvation, since every job eventually reaches the front.

Its flaw is serious, though. Because a job runs to completion once started, a long job at the front makes every short job behind it wait the full long duration — this is the convoy effect, and it can wreck average waiting time and response time. FCFS also behaves badly for interactive use, since a CPU-bound job can hold the processor while quick I/O-bound jobs pile up behind it. It is rarely used alone in general-purpose systems, but it often serves as the tie-breaking rule inside more sophisticated schedulers.

Jobs arrive nearly together: P1 needs 24 ms, P2 needs 3 ms, P3 needs 3 ms, in that order. FCFS gives waiting times 0, 24, 27, averaging 17 ms. Had the two short jobs gone first, the average would have been far lower — FCFS is at the mercy of arrival order.

FCFS is fair and starvation-free, but one long job at the head punishes everyone behind it.

FCFS is free of starvation but not of fairness problems: it is fair in ORDER yet wildly unfair in WAITING TIME, since a short job can wait far longer than its own length behind a long one.

Also called
FCFSFIFO scheduling先進先出排程