Day 02Part 04 – Operating system for gate computer – First come first serve basic algorithms (FCFS)
Day 02Part 04 – Operating system for gate computer – First come first serve basic algorithms (FCFS)
Contents [hide]
- 0.1 First Come First Serve (FCFS) Scheduling Algorithm
- 0.2 Day 02Part 04 – Operating system for gate computer – First come first serve basic algorithms (FCFS)
- 0.3 OPERATING SYSTEM Lecture Notes On
- 0.4 Lab Manual – OPERATING SYSTEMS
- 0.5 Unit IV – CPU Scheduling and Algorithm
- 1
What is FCFS (First Come First Serve)?
- 2
Key Characteristics:
- 3
Example of FCFS Scheduling
- 4
Average Time Calculations
- 5
Disadvantages of FCFS:
- 6
Advantages of FCFS:
- 7
Tip for GATE Exam:
First Come First Serve (FCFS) Scheduling Algorithm
Introduction
First Come First Serve (FCFS) is the simplest CPU scheduling algorithm, where the process that arrives first in the ready queue gets executed first. It follows the FIFO (First In, First Out) principle.
Characteristics of FCFS:
Non-Preemptive: Once a process starts execution, it cannot be stopped until it completes.
Simple and Easy: The implementation is straightforward using a queue.
Fairness: Every process gets CPU time based on arrival order.
Not Optimal: High waiting time due to the Convoy Effect (slower processes delay faster ones).
Example of FCFS Scheduling:
Let’s consider 3 processes with the following arrival and burst times:
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 ms | 5 ms |
P2 | 1 ms | 3 ms |
P3 | 2 ms | 8 ms |
Step-by-Step Execution Order (Gantt Chart):
Calculations in FCFS:
1. Completion Time (CT):
-
P1 finishes at 5 ms
-
P2 finishes at 8 ms
-
P3 finishes at 16 ms
2. Turnaround Time (TAT):
TAT=CT−ArrivalTimeTAT = CT – Arrival Time
-
P1 = 5 – 0 = 5
-
P2 = 8 – 1 = 7
-
P3 = 16 – 2 = 14
3. Waiting Time (WT):
WT=TAT−BurstTimeWT = TAT – Burst Time
-
P1 = 5 – 5 = 0
-
P2 = 7 – 3 = 4
-
P3 = 14 – 8 = 6
Average Turnaround Time:
(5+7+14)/3=8.67ms(5 + 7 + 14) / 3 = 8.67 ms
Average Waiting Time:
(0+4+6)/3=3.33ms(0 + 4 + 6) / 3 = 3.33 ms
Advantages of FCFS:
Easy to implement (uses a queue).
Fair for all processes (executes in order of arrival).
Disadvantages of FCFS:
Convoy Effect (a long process can delay all others).
Higher Average Waiting Time compared to other scheduling algorithms.
Conclusion
FCFS is a simple but inefficient CPU scheduling algorithm, suitable for basic systems but not ideal for time-sharing systems due to high waiting times. Other scheduling algorithms like SJF (Shortest Job First) and Round Robin perform better in most real-world scenarios.
Day 02Part 04 – Operating system for gate computer – First come first serve basic algorithms (FCFS)
OPERATING SYSTEM Lecture Notes On
Lab Manual – OPERATING SYSTEMS
Unit IV – CPU Scheduling and Algorithm
Here is a complete and simple explanation of First Come First Serve (FCFS) — the basic CPU scheduling algorithm in Operating Systems, commonly covered in Day 02 Part 04 of GATE/Computer Science prep.
What is FCFS (First Come First Serve)?
First Come First Serve (FCFS) is the simplest CPU scheduling algorithm where the process that arrives first is executed first.
It’s like a queue at a ticket counter — whoever comes first gets served first.
Key Characteristics:
Feature | Description |
---|---|
Scheduling Type | Non-preemptive |
Basis of Execution | Arrival Time |
Implementation | Simple FIFO Queue (First In First Out) |
Starvation Possible? | |
Best for | Batch systems |
Poor Performance When | Longer processes arrive before shorter ones |
Example of FCFS Scheduling
Let’s take 3 processes:
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 ms | 4 ms |
P2 | 1 ms | 3 ms |
P3 | 2 ms | 1 ms |
Step 1: Order of Execution (based on Arrival Time)
→ P1 → P2 → P3
Step 2: Gantt Chart
Step 3: Calculate Completion, Turnaround, and Waiting Time
Process | Arrival | Burst | Completion | Turnaround | Waiting |
---|---|---|---|---|---|
P1 | 0 | 4 | 4 | 4 | 0 |
P2 | 1 | 3 | 7 | 6 | 3 |
P3 | 2 | 1 | 8 | 6 | 5 |
Turnaround Time = Completion – Arrival
Waiting Time = Turnaround – Burst
Average Time Calculations
-
Average Turnaround Time = (4 + 6 + 6) / 3 = 5.33 ms
-
Average Waiting Time = (0 + 3 + 5) / 3 = 2.67 ms
Disadvantages of FCFS:
-
Convoy Effect: Long process delays short ones.
-
Poor average waiting time in some cases.
-
Not suitable for interactive systems.
Advantages of FCFS:
-
Simple and easy to implement.
-
Fair — in the sense that it serves in order of arrival.
Tip for GATE Exam:
-
Always sort by arrival time first.
-
Use a Gantt Chart to visualize execution.
-
Watch out for arrival delays while calculating waiting times.
Let me know if you want:
-
FCFS code implementation in C/Python,
-
MCQs, or
-
Comparison with SJF, Round Robin, etc