How First Come First Served works
First Come First Served (FCFS) is the simplest CPU scheduling algorithm: processes get the CPU in the order they arrive. When the CPU becomes free, the scheduler takes the process that has been in the ready queue the longest, and that process keeps the CPU until its whole burst is done. Nothing can interrupt it, so FCFS is non-preemptive.
Two details decide every schedule. If two processes arrive at the same time, Trace gives the CPU to the lower process number first, so P1 goes before P2. If nothing is ready when the CPU frees up, the CPU sits idle until the next arrival, and the timeline shows that gap as idle time.
The behavior to remember is the convoy effect. One long process at the front of the queue makes every short process behind it wait for its entire burst, much like cars stuck behind a slow truck on a single-lane road. FCFS looks only at arrival order, never at how long a job is, so the same work can produce very different waiting times depending on who shows up first.
Because each process runs exactly once, from start to finish, its response time and its waiting time are always the same number under FCFS. That stops being true for the preemptive algorithms, where a process can start, stop and wait again.
Worked example
Three processes arrive at time 0 with bursts of 24, 3 and 3 units. They all arrive together, so the tie rule puts P1 first, and the two short jobs wait behind the long one.
FCFS. Order of execution: P1 0 to 24, P2 24 to 27, P3 27 to 30.
| Process | Arrival | Burst | Finished | Turnaround | Waiting | Response |
|---|---|---|---|---|---|---|
| P1 | 0 | 24 | 24 | 24 | 0 | 0 |
| P2 | 0 | 3 | 27 | 27 | 24 | 24 |
| P3 | 0 | 3 | 30 | 30 | 27 | 27 |
| Average | 27 | 17 | 17 |
The average waiting time is (0 + 24 + 27) / 3 = 17. Now imagine the two short jobs had arrived a moment before P1. The order becomes P2, P3, P1 and the average wait drops to (0 + 3 + 6) / 3 = 3, with exactly the same amount of work. That gap is the convoy effect in numbers.
Formulas
- Turnaround time
= finished - arrival - Waiting time
= turnaround - burst - Response time
= first run - arrival
Take P3 from the example: it finishes at 30 and arrived at 0, so its turnaround time is 30. Its burst is 3, so it spent 30 - 3 = 27 units waiting. It started at 27, which makes its response time 27 as well, as expected for FCFS. Averages are the sum over all processes divided by the number of processes. The simulator shows them to two decimals and gives the exact fraction when you hover or focus the number.
Strengths and weaknesses
Strengths
- Easy to understand and to implement with a single queue.
- No starvation: every process that arrives eventually runs.
- Very little scheduling work, since a decision is needed only when a process finishes.
Weaknesses
- The convoy effect: short jobs stuck behind a long one inflate the average waiting time.
- A poor fit for interactive use, because one long job delays everything behind it.
- No way for an urgent process to get ahead, since nothing is ever preempted.
Common exam mistakes
- Ordering by process number instead of arrival time. If P3 arrives at time 1 and P2 at time 2, P3 runs first. Process numbers only break ties between equal arrival times.
- Forgetting idle time. If the first process arrives at time 2, the CPU is idle from 0 to 2. The timeline starts at 0, and the idle stretch lowers CPU utilization.
- Using the start time as the waiting time. That only works when the process arrived at 0. In general waiting time is start time minus arrival time for FCFS.
- Measuring turnaround from time 0. Turnaround runs from the moment the process arrives, not from the start of the timeline.
Related
Spotted a mistake?
If a number or a sentence on this page looks wrong, please say so. Include the processes you entered, or paste the link from "Copy link".
Email: abdul at abmans dot com