FCFS First Come First Serve CPU Scheduling (original) (raw)

Last Updated : 6 Jan, 2026

First Come, First Serve (FCFS) is one of the simplest types of CPU scheduling algorithms. It is exactly what it sounds like: processes are attended to in the order in which they arrive in the ready queue, much like customers lining up at a grocery store.

FCFS Scheduling is a non-preemptive algorithm, meaning once a process starts running, it cannot be stopped until it voluntarily relinquishes the CPU, typically when it terminates or performs I/O. This method schedules processes in the order they arrive, without considering priority or other factors.

**How Does FCFS Work?

The mechanics of FCFS are straightforward:

  1. **Arrival: Processes enter the system and are placed in a queue in the order they arrive.
  2. **Execution: The CPU takes the first process from the front of the queue, executes it until it is complete, and then removes it from the queue.
  3. **Repeat: The CPU takes the next process in the queue and repeats the execution process.

This continues until there are no more processes left in the queue.

Example of FCFS CPU Scheduling:

To understand the First Come, First Served (FCFS) scheduling algorithm effectively, we'll use two examples -

We'll create Gantt charts for both scenarios and calculate the turnaround time and waiting time for each process.

Scenario 1: Processes with Same Arrival Time

Consider the following table of arrival time and burst time for three processes P1, P2 and P3

Process Arrival Time Burst Time
p1 0 5
p2 0 3
p3 0 8

**Step-by-Step Execution:

  1. **P1 will start first and run for 5 units of time (from 0 to 5).
  2. **P2 will start next and run for 3 units of time (from 5 to 8).
  3. **P3 will run last, executing for 8 units (from 8 to 16).

**Gant Chart:

Now, let's calculate average waiting time and turn around time:

Turnaround Time = Completion Time - Arrival Time
Waiting Time = Turnaround Time - Burst Time

**AT : Arrival Time
**BT : Burst Time or CPU Time
**TAT : Turn Around Time
**WT : Waiting Time

Processes AT BT CT TAT WT
P1 0 5 5 5-0 = 5 5-5 = 0
P2 0 3 8 8-0 = 8 8-3 = 5
P3 0 8 16 16-0 = 16 16-8 = 8

Scenario 2: Processes with Different Arrival Times

Consider the following table of arrival time and burst time for three processes P1, P2 and P3

**Process **Burst Time (BT) **Arrival Time (AT)
P1 5 ms 2 ms
P2 3 ms 0 ms
P3 4 ms 4 ms
Step-by-Step Execution:
Gantt Chart:

Now, lets calculate average waiting time and turn around time:

**Process **Completion Time (CT) **Turnaround Time (TAT = CT - AT) **Waiting Time (WT = TAT - BT)
P2 3 ms 3 ms 0 ms
P1 8 ms 6 ms 1 ms
P3 12 ms 8 ms 4 ms

Code Implementation

**Advantages of FCFS

Disadvantages of FCFS