FCFS Scheduling Algorithm

FCFS

First come first serve (FCFS) scheduling algorithm simply execute the jobs/process according to their arrival time. The process which comes first in the ready queue will get the CPU first.

Example: 1

Criteria: Non-Preemptive

Mode: Process Arriving in the order and first process have more Burst Time

Let’s take an example of The FCFS scheduling algorithm. In the Following schedule, there are 3 processes with process P1, P2 and P3. P1 arrives at time 0, P2 at time 1 and P3 arrives at time 2 in the ready queue. The processes and their respective Arrival and Burst time are given in the following table.

ProcessBurst Time
P124
P23
P33

Solution

Lets draw the Gantt Chart. Suppose the process arrive in the order P1,P2,P3

             (Gantt chart)

Start Time/Wait Time for first process is 0 always if arrival time not given.

Waiting Time for P1 => 0

Waiting Time for P2 => 24

Waiting Time for P3 => 27

ProcessBurst TimeWaiting Time
P1240
P2324
P3327

               Average Waiting Time(AWT) =(0+24+27)/3

= 51/3

= 17

Example: 2

Criteria: Non-Preemptive

Mode: Process Arriving in Different order and first process have low Burst Time

Suppose the process arrive in the order P3,P2, P1

ProcessBurst Time
P33
P23
P124

Solution

             (Gantt chart)

Waiting Time for P1 => 6

Waiting Time for P2 => 3

Waiting Time for P3 => 0

ProcessBurst TimeWaiting Time
P330
P233
P1246

Average Waiting Time(AWT) =(6+3+0)/3

= 9/3

= 3

Advantages of FCFS

  • Simplest form of CPU Scheduling Algorithm
  • Easy to Program
  • First come, First served like FIFO Queue Model

Disadvantages of FCFS

  1. Poor Performance
  2. Average waiting time is higher as compare to other scheduling algorithms.
  3. It is a Non-Preemptive CPU scheduling algorithm, so after the process has been allocated to the CPU, it will never release the CPU until it finishes executing.
  4. Average Waiting Time is not optimal
  5. Cannot utilize resources in parallel. Convoy Effect may occur

Convoy Effect in FCFS

Convoy Effect can occur in FCFS like suppose the first process which arrived in the queue has a huge burst time…so for that time all other processes will have to wait…this is convoy effect like a minister is crossing the road and all other traffic has to wait for some time….but it will not be infinite…all processes will eventually get a chance..

Convoy effect in Operating System is a phenomenon (in First come First serve) in which whole operating system slows down due to few slow process. As FCFS is a non-preemptive scheduling algorithm, the CPU will be allocated to a process until it get finished, that means other processes have to wait for their turn.

Starvation is the phenomena in which a process is not able to acquire the desired resources (like processor, I/O device etc) for a very long time to progress with its execution.

A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting in both programs ceasing to function.

Leave a Reply 0

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