First Come First Serve FCFS CPU Scheduling Algorithm

For Complete YouTube Video: Click Here

This class will try understanding the First Come First Serve FCFS CPU Scheduling Algorithm.

In our previous classes, we had a detailed explanation of CPU Scheduling and Types of CPU Scheduling.

First Come First Serve FCFS CPU Scheduling Algorithm

The First Come First Serve FCFS CPU Scheduling Algorithm schedules the jobs according to their arrival time.

It is a non-preemptive scheduling algorithm.

To understand this concept, we will consider the example shown below.

In the above example, we have three columns.

The first column is the process number, the second column is the arrival time of the processes, and the third column is the process’s burst time.

We can use the Gant chart below to understand and analyze any CPU scheduling algorithm.

We will start our analysis with the 0th point in time.

The 0th time is the point in time at which the execution of the processes will start.

At the 0th time, we have only one process P1 in the ready queue, so we will switch the process P1 to the running state.

As a first come first serve FCFS CPU scheduling algorithm is non-preemptive, the process P1 will continue until completion.

As the burst time of the process is two units, process P1 will complete its execution after 2nd second, as shown below.

By the end of two-time units, processes P2 and P3 will be in the ready state.

Now we have to choose one process for both of them.

As FCFS choose based on arrival time, we will switch process P2 onto the CPU.

As the burst time of the P2 is five, the process P2 will be in the ready state until the seventh unit in time, as shown below.

Similarly, we will choose the remaining processes based on the arrival time shown below.

Process P3 is selected for execution.

Process P4 is selected for execution.

Process P5 is selected for execution.

From the above Gantt chart, we will now find the completion time.

Completion time is the time at which the process will complete its execution.

The table with the completion time is shown below.

Now, we will find the Turn Around Time of all the processes.

In our previous classes, we have already discussed that “TAT = CT – AT.”

The image below shows the Turn Around Time of all the processes.

Similarly, we will find the Waiting Time of all the processes.

Waiting time = Turn Around Time [TAT] – Burst Time [BT].

The image below is the table with the waiting time for all the processes.