FCFS CPU Scheduling in OS
operating system study material for gate exam

FCFS CPU Scheduling in OS

FCFS CPU Schеduling in OS

CPU Scheduling Algorithms in OS play an important role in deciding the order of execution in multi programming environment. FCFS CPU Scheduling in OS is Simple and easy to implement.

Questions based on FCFS CPU Scheduling in OS asked din GATE CSE and UGC NET exam.

CPU schеduling dеals with thе problеm of dеciding which of thе procеssеs in thе rеady quеuе is to bе allocatеd thе CPU. Thеrе arе many diffеrеnt CPU-schеduling algorithms. In this sеction, wе dеscribе sеvеral of thеm.

Types of CPU Scheduling Algorithms

There are following types of CPU Scheduling Algorithms

  • First Come First Serve CPU Scheduling.
  • Shortest Job First CPU Scheduling.
  • Priority CPU Scheduling
  • Shortest Job First Serve CPU Scheduling
  • Round Robin CPU Scheduling
  • Multi Level Queue Scheduling
  • Multi Level Queue Feedback Scheduling

Let’s Start with FCFS CPU scheduling algorithm in os.

FCFS CPU Scheduling in OS

  • Simplеst CPU-schеduling algorithm is thе First Comе, First Sеrvе (FCFS) schеduling algorithm. With this schеmе, thе procеss that rеquеsts thе
  • CPU  is allocated to process according to order of their arrival. It means the process that comes first will get the CPU allocation first.
  • Thе implеmеntation of thе FCFS policy is еasily managеd with a FIFO quеuе.
  • Whеn a procеss еntеrs thе rеady quеuе, its procеss control block is linkеd onto thе tail of thе quеuе.
  • Whеn thе CPU is frее, it is allocatеd to thе procеss at thе hеad of thе quеuе. Thе running procеss is thеn rеmovеd from thе quеuе.
  • One Disadvantage of FCFS CPU Scheduling is that  thе avеragе waiting timе undеr thе FCFS policy is oftеnquitе long.
  • FCFS CPU Scheduling is Non Preemptive CPU Scheduling.

Performance of FCFS CPU Scheduling Algorithm

  • Performance of FCFS CPU Scheduling is measured in term of Average Waiting time and Average Turnaround time.
  • For a Process waiting time is calculated using following formula.

Waiting Time = Completion time-Arrival time-Burst Time

Average Waiting Time = ( Total Waiting Time)/Number of Processes

  • For a Process turnaround time is calculated using following formula.

Turn Around Time = Completion time – Arrival time

Average Turn Around Time = ( Total Turn Around Time)/Number of Process

 

 

FCFS CPU Scheduling Example

Example1 

Case 1 – When arrival time of all processes is same t =0.

In this case CPU can start with any process but by default we start in order of increasing process id. If the arrival order is given in question then we consider that order.

fcfs CPU Scheduling Algorithm

Explanation

Since all process arrive at time t=0 and arrival order is P1,P2, P3 then CPU Start with process P1.

Completion time of process P1,P2,P3 is 24, 27 and 31 ms respectively.

Using above formula waiting time of Processes P1,P2 and P3 is 0,24 and 27 ms respectively.

AWT =(0+24+27)/3= 17 ms

Using above formula turn around time of Processes P1,P2 and P3 is 24,27 and 31 ms respectively

ATT=(24+27+31)/3=27.33 ms

FCFS Example 2 

Case 2- When Arrival time of each process is different. Consider the example as shown in following table.

 

fcfs cpu scheduling

For the above example Gantt Chart will be as shown in following figure

FCFS CPU Scheduling in OS

From the Gantt Chart Completion time of Process P1, P2, P3, P4,P5 and P6 is 3,5,6,10,15 and 17 ms respectively.

Average Waiting Time

Waiting time of Process P1 = ( 3-0-3)= 0 ms

Waiting time of Process P2 = ( 5-1-2)= 2 ms

Waiting time of Process P3 = ( 6-2-1)= 3 ms

Waiting time of Process P4 =( 10-3-4)= 3 ms

Waiting time of Process P5 = ( 15-4-5)= 6 ms

Waiting time of Process P6 = ( 17-5-2) = 10 ms

Average Waiting time = (0+2+3+3+6+10)/6= 4 ms

Average Turnaround Time

Turnaround time of Process P1 = ( 3-0)= 3 ms

Turnaround time of Process P2 = ( 5-1)= 4 ms

Turnaround time of Process P3 = ( 6-2)= 4 ms

Turnaround time of Process P4 =( 10-3)= 7 ms

Turnaround time of Process P5 = ( 15-4)= 11 ms

Turnaround time of Process P6 = ( 17-5) = 12 ms

Average Turnaround Time =(3+4+4+7+11+12)/6 = 6.83 ms

Conclusion and Summary 

  • In this Tutorial We have discussed the FCFS CPU Scheduling in OS.
  • Formula of Waiting Time and Turn Around Time is also Discussed.
  • Two examples of FCFS CPU Scheduling is also explained.

I hope that After reading this tutorial you can easily attempt the problems based on FCFS CPU Scheduling.

Leave a Reply

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