/    /  OS – FCFS Scheduling Algorithm

FCFS Scheduling Algorithm

 

First Come First Serve or FCFS is an operating system scheduling algorithm that automatically executes queued processes in order of their arrival. 

 

Characteristics of FCFS method:

  1. Easier to implement and use. 
  2. The general wait time is very high. 
  3. FCFS method is poor in performance.
  4. FCFS method supports preemptive and non-preemptive scheduling algorithms. 

 

Example of FCFS Scheduling:

A real-life example of FCFS scheduling can be buying tickets at the ticket counter. It is similar to the FIFO queue data structure, the element that is in the queue first will leave the queue first. 

FCFS Scheduling is used in Batch operating systems.

 

Advantages of FCFS:

 

The advantages of FCFS are as follows:

  1. It is easy to use.
  2. It is a simple scheduling algorithm.
  3. It follows first come, first serve.

 

Disadvantages of FCFS:

 

The disadvantages of FCFS are as follows:

  1. There is a problem of starvation as FCFS is non-preemptive in nature.
  2. It has a more average waiting time. 
  3. FCFS is not suitable for time-sharing systems.
  4. It is not possible to use resources in a parallel manner in FCFS.
  5. Only after the completion of a process, the CPU becomes free for the execution of a process that is first in the queue.

What is the Convoy Effect?

Long processes can be holding the CPU, causing the short processes to wait for a long time, this is known as the convoy effect.

This affects the performance of the operating system, and also leads to poor utilization of the resources.

Example of FCFS Scheduling:

We can take an example of five processes having different burst times.

 

ProcessBurst TimeArrival Time
P162
P235
P381
P430
P544

 

The processes will be handled as follows:

It will start with P4, arrival time 0.

Step 1: At time=1, P3 arrives. As P4 is still executing, P3 is in the queue. 

Step 2: At time=2, P1 arrives. 

Step 3: At time=3, P4 completes its execution.

Step 4: At time=4, P3 is executed as it is first in the queue.

Step 5: At time=5, P2 arrives and is kept in a queue.

Step 6: At time=11, P3 completes its execution.

Step 7: At time=11, P1 starts to execute and it completes its execution at time interval 17.

Step 8: At time= 17, P5 starts to execute and it completes execution at time=21.

Step 9: At time= 21, P2 starts to execute and completes its execution at time interval 23.

Step 10: To calculate the average waiting time:

P4 = 0-0 = 0

P3 = 3-1 = 2

PI = 11-2 = 9

P5= 17-4 = 13

P2= 21-5= 16

Average Waiting Time

(0+2+9+13+16)/5

= 40/5= 8

Reference:

FCFS Scheduling Algorithm In OS.