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).

play-rounded-fill play-rounded-outline play-sharp-fill play-sharp-outline
pause-sharp-outline pause-sharp-fill pause-rounded-outline pause-rounded-fill
00:00

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

1. Introduction to FCFS Scheduling

  • First Come, First Serve (FCFS) is the simplest CPU scheduling algorithm.
  • The process that arrives first gets executed first.
  • It is non-preemptive, meaning once a process starts, it cannot be interrupted until it finishes.

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).

Unit IV – CPU Scheduling and Algorithm

Operating System : Scheduling Algorithm

Here’s a clear and complete explanation for:

🖥️ Operating Systems – Day 02 Part 05

🔢 Examples Based on First Come First Serve (FCFS) Scheduling Algorithm


📌 What is FCFS?

FCFS (First Come First Serve) is the simplest scheduling algorithm in operating systems.

  • Jobs are executed in the order they arrive in the ready queue.
  • It is non-preemptive.
  • Think of it like a queue at a ticket counter.

📋 Terminology

Term Meaning
Arrival Time (AT) Time at which process enters the ready queue
Burst Time (BT) Time required by process to execute
Completion Time (CT) Time when process finishes execution
Turnaround Time (TAT) CT−ATCT – AT
Waiting Time (WT) TAT−BTTAT – BT

🧮 Example 1 (With Same Arrival Time)

👇 Given:

Process Arrival Time (AT) Burst Time (BT)
P1 0 5
P2 0 3
P3 0 8
P4 0 6

All processes arrive at time 0.

🕐 Execution Order: P1 → P2 → P3 → P4

📊 Calculations:

Process AT BT CT TAT = CT-AT WT = TAT-BT
P1 0 5 5 5 0
P2 0 3 8 8 5
P3 0 8 16 16 8
P4 0 6 22 22 16

📈 Gantt Chart:

| P1 | P2 | P3 | P4 |
0    5    8   16   22

🧮 Example 2 (With Different Arrival Times)

👇 Given:

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

Processes are executed in arrival order.

🕐 Execution Order: P1 → P2 → P3 → P4

📊 Calculations:

Process AT BT CT TAT WT
P1 0 4 4 4 0
P2 1 3 7 6 3
P3 2 1 8 6 5
P4 3 2 10 7 5

📈 Gantt Chart:

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

📌 Pros and Cons of FCFS

✅ Advantages:

  • Simple to implement.
  • Easy to understand.

❌ Disadvantages:

  • Convoy effect: Short processes wait for long ones.
  • Poor average waiting time in some cases.
  • Non-preemptive → not ideal for time-sharing systems.

🧠 Formula Summary

  • Turnaround Time (TAT) = Completion Time – Arrival Time
  • Waiting Time (WT) = Turnaround Time – Burst Time

Would you like practice questions, a Python code implementation, or comparison with SJF/Round Robin next?

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



Leave a Reply

Your email address will not be published. Required fields are marked *

error: