First Come First Served (FCFS)
Simulate FCFS CPU scheduling with your own arrival and burst times. Follow the Gantt chart, calculate waiting and turnaround times, and see the convoy effect.
Skip to the animationFirst Come First Served runs processes in the exact order they arrived, and never interrupts one — the scheduling equivalent of a single queue at a counter.
How it works
The ready queue is a plain FIFO queue. A process arriving is pushed on the back; when the CPU frees up, the process at the front is dispatched and runs until it finishes or blocks. There is no priority, no estimate, no preemption — nothing to compute, which is why it is the easiest scheduler to implement and the baseline everything else is compared to.
The vocabulary
- Arrival time
- When the process shows up in the ready queue. The scheduler cannot pick something that has not arrived yet — that single rule decides most exam answers.
- Burst time
- How long this process needs the CPU for, uninterrupted, before it would block or finish. Also called CPU burst.
- Ready queue
- Every process that could run right now but does not have the CPU. Scheduling is entirely the question of who gets pulled out of here next.
- Preemptive vs non-preemptive
- A non-preemptive scheduler cannot take the CPU back — once dispatched, a process runs until it blocks or finishes. A preemptive one can interrupt it mid-burst.
- Context switch
- Saving one process's registers and loading another's. Pure overhead: real work stops while it happens, typically a few microseconds.
- Starvation
- A process that stays runnable but never gets picked, because something more attractive keeps arriving. The classic fix is ageing — slowly raising the priority of anything that has waited a long time.
The convoy effect
FCFS has one serious flaw, and it is worth being able to state precisely: average waiting time depends heavily on the order of arrival, and one long job at the front penalises everyone behind it.
Take three processes all arriving at t = 0 — P1 with a burst of 24, P2 with 3, P3 with 3. In the order P1, P2, P3:
| Process | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|
| P1 | 24 | 24 | 24 | 0 |
| P2 | 3 | 27 | 27 | 24 |
| P3 | 3 | 30 | 30 | 27 |
Average waiting time is (0 + 24 + 27) ÷ 3 = 17. Now run exactly the same processes in the order P2, P3, P1: waiting times become 0, 3 and 6, an average of 3. Same work, same machine, nearly six times better — purely because the short jobs went first.
That pile-up of short jobs behind one long one is the convoy effect. In a real system it is worse than the numbers suggest: the I/O devices sit idle while the CPU-bound job hogs the processor, then everything stampedes at once.
Where it is actually used
Never on its own in an interactive system — a single long job would freeze the machine. It survives as the tie-breaking rule *inside* other schedulers (processes of equal priority are usually served FCFS) and in batch settings where throughput matters and nobody is waiting at a screen.
The numbers you will be asked for
- Turnaround time
completion − arrival
Total time the process spent in the system, from the moment it arrived to the moment it finished.
- Waiting time
turnaround − burst
The part of that which was pure waiting. It is the only part a scheduler can actually change — the burst is fixed work.
- Response time
first run − arrival
How long until the process gets the CPU for the first time. This is what an interactive user actually feels.
- Throughput
processes ÷ total time
How much work the machine completes per unit of time.
Advantages and disadvantages
Advantages
- Trivial to implement — one FIFO queue, no bookkeeping.
- Perfectly fair in the arrival-order sense, and completely free of starvation: everyone eventually reaches the front.
- No context switch overhead beyond the unavoidable minimum.
Disadvantages
- Average waiting time is high and swings wildly with arrival order.
- The convoy effect: one long job blocks every short job behind it.
- Terrible response time, so it is unusable for interactive work.
- Non-preemptive, so an urgent process cannot jump ahead no matter what.
Watch it work
Check yourself
question 1 / 4
One question at a time. Pick an answer to see why it is right or wrong, then move on — there is no score to keep and nothing is saved.