DIZNR INTERNATIONAL

Day 02Part 05 – Operating system- Examples based on First come first serve basic algorithms (FCFS).

Day 02Part 05 – Operating system- Examples based on First come first serve basic algorithms (FCFS).

https://www.gyanodhan.com/video/7B7.%20GATE%20CSEIT/Operating%20System/409.%20Day%2002Part%2005%20-%20Operating%20system-%20Examples%20%20based%20on%20First%20come%20first%20serve%20basic%20algorithms%20%28FCFS%29.mp4

First Come, First Serve (FCFS) Scheduling – Examples & Explanation

1. Introduction to FCFS Scheduling

2. Steps to Implement FCFS Scheduling

Sort processes by their arrival time (earliest first).
Execute each process in the order of arrival.
Compute the completion, turnaround, and waiting times.

3. Example of FCFS Scheduling

Given Data

Process Arrival Time (AT) Burst Time (BT)
P1 0 ms 4 ms
P2 1 ms 3 ms
P3 2 ms 1 ms
P4 3 ms 2 ms

Step 1: Compute Completion Time (CT)

FCFS executes processes in the order they arrive.

Process AT BT Start Time Completion Time (CT)
P1 0 4 0 4
P2 1 3 4 7
P3 2 1 7 8
P4 3 2 8 10

Step 2: Compute Turnaround Time (TAT)

TAT=CT−ATTAT = CT – AT

Process CT AT TAT (CT – AT)
P1 4 0 4
P2 7 1 6
P3 8 2 6
P4 10 3 7

Step 3: Compute Waiting Time (WT)

WT=TAT−BTWT = TAT – BT

Process TAT BT WT (TAT – BT)
P1 4 4 0
P2 6 3 3
P3 6 1 5
P4 7 2 5

Step 4: Calculate Average Times

Average Turnaround Time=4+6+6+74=5.75 ms\text{Average Turnaround Time} = \frac{4 + 6 + 6 + 7}{4} = 5.75 \text{ ms} Average Waiting Time=0+3+5+54=3.25 ms\text{Average Waiting Time} = \frac{0 + 3 + 5 + 5}{4} = 3.25 \text{ ms}

4. Gantt Chart Representation

| P1 |----4ms----| P2 |----7ms----| P3 |----8ms----| P4 |----10ms----|
0 4 7 8 10

5. Key Observations in FCFS

Simple and easy to implement.
Works well for smaller processes.
Not optimal for minimizing waiting time.
Suffers from “Convoy Effect” – when a long process delays shorter ones.

Would you like a Python/C program to simulate FCFS?

Day 02Part 05 – Operating system- Examples based on First come first serve basic algorithms (FCFS).