First come first served scheduling algorithm (FCFS)




First come first served scheduling algorithm (FCFS)

FCFS also termed as First-In-First-Out i.e. allocate the CPU in order in which the process arrive. When the CPU is free, it is allowed to process, which is occupying the front of the queue. Once this process goes into running state, its PCB is removed from the queue. This algorithm is non-preemptive.

Advantage
  • Suitable for batch system.
  • It is simple to understand and code.
Disadvantage
  • Waiting time can be large if short request wait behind the long process.
  • It is not suitable for time sharing system where it is important that each user should get the CPU for equal amount of time interval.
Examples
consider the following set of processes having their CPU-burst time. CPU burst time indicates that for how much time, the process needs the CPU. If the processes have arrived in order P0, P1, P2, P3 then the average waiting time for process will be obtained from Gantt chart.





In this post, we have assumed arrival times as 0, so turn around and completion times are same



Completion Time: Time at which process completes its execution.
Turn Around Time: Time Difference between completion time and arrival time.
 Turn Around Time = Completion Time – Arrival Time
Waiting Time (W.T): Time Difference between turnaround time and burst time.
Waiting Time = Turn Around Time – Burst Time




Average waiting time = 17.25
Average turnaround time = 25.25

below example without  arrival time
 



Thus average waiting time will always depends upon the order in which the processes arrive. And vary depending upon whether the processes having less CPU-burst arrive first in the ready queue. Therefore this algorithm is never recommended whenever performance is major issue.

  

Comments

Popular posts from this blog

Write C programs to simulate the Paging techniques of memory management

Write C programs to simulate the Two level directory File organization technique

Write C programs to simulate the Hierarchical directory File organization technique