Implementation OF FCFS ScheDULing Algorithm

Implementation of FCFS Scheduling algorithm.

FCFS Scheduling

The first come first serve (FCFS) scheduling algorithm simply schedules the jobs according to their arrival time. The job which comes first in the ready queue will get the CPU first. The lesser the arrival time of the job, the sooner will the job gets the CPU. FCFS scheduling may cause the problem of starvation if the burst time of the first process is the longest among all the jobs.

The FCFS scheduling algorithm. In the Following schedule, there are 5 processes with process ID P0, P1, P2, P3, and P4. P0 arrives at time 0, P1 at time 1, P2 at time 2, P3 arrives at time 3, and Process P4 arrives at time 4 in the ready queue. The processes and their respective Arrival and Burst time are given in the following table.



  • Input the processes along with their burst time (bt).
  •  Find waiting time (wt) for all processes.
  • As the first process that comes needs not to wait so the waiting time for process 1 will be 0 e. wt[0] = 0.
  • Find waiting time for all other processes e. for process i ->wt[i] = bt[i-1] + wt[i-1] .
  • Find turnaround time = waiting_time + burst_time for all processes.
  • Find average waiting time =total_waiting_time / no_of_processes.
  • Similarly, find average turnaround time =total_turn_around_time / no_of_processes.

The Turnaround time and the waiting time are calculated by using the following formula.

  1. Turn Around Time = Completion Time – Arrival Time
  2. Waiting Time = Turnaround time – Burst Time

The average waiting time is determined by summing the respective waiting time of all the processes and divided the sum by the total number of processes.


Process ID Arrival Time Burst Time Completion Time Turn Around Time Waiting Time
0 0 2 2 2 0
1 1 6 8 7 1
2 2 4 12 8 4
3 3 9 21 18 9
4 4 12 33 29 17

Avg Waiting Time=31/5


                  (Gantt chart)


Design front page of the hospital with different style sheets.->>>click Here

1 thought on “Implementation OF FCFS ScheDULing Algorithm”

Leave a Comment