# Relation in FCFS and Preemptive Priority Scheduling Algorithm

In this article, we will see how FCFS is a special kind of Priority Preemptive Scheduling Algorithm. Also, we will cover the relation with each other. Let us discuss one by one.

1. First Come First Serve (FCFS) Scheduling Algorithm :
FCFS is the simplest of CPU Scheduling Algorithm which executes the process that comes first. It is a non-preemptive algorithm. The process that arrives first in the ready queue gets to be executed by the CPU first, then the second one, then the third one, and so on. The arrival time of processes is the deciding factor here. Ready queue acts like FIFO (First In First Out) queue.

Example –
Here is a list of processes, their arrival time, and burst time. The Gantt Chart shows how they are executed.

PROCESS ARRIVAL TIME BURST TIME
P1 0 10
P2 3 5
P3 5 2
P4 6 6
P5 8 4

As the processes approach in the ready queue, they are sent one by one to the CPU to be executed. Until and unless the first arriving process completes its execution, the next one does not get a chance.

2. Preemptive Priority Scheduling Algorithm :
In Preemptive Priority Scheduling Algorithm, the processes come with a priority attached to them. The lower the priority number, the higher is the priority attached to the process. A process with higher priority on its arrival preempts an ongoing process. It gets the CPU. The process with priority 1 always gets the CPU whenever it arrives and is never preempted. It has a response time of 0. Equal priority processes are scheduled in the FCFS order.

Example –
Here is a list of processes, their arrival time, and burst time. The Gantt Chart shows how they are executed.

PROCESS ARRIVAL TIME BURST TIME PRIORITY
TOTAL REMAINING
P1 0 4 4 4
P2 1 3 3 3
P3 3 4 4 1
P4 6 2 2 5
P5 8 4 4 2

FCFS is a special kind of Preemptive Priority Scheduling Algorithm :
FCFS executes the process that appears first in the ready queue. That means it attaches priority to the arrival time of the process. The process that comes first gets higher priority over the other processes and hence gets the CPU first. So, we say FCFS is a special kind of Preemptive Priority Scheduling Algorithm where earlier arrival time has a higher priority.

Preemptive Priority is a special kind of FCFS Scheduling Algorithm :
Preemptive Priority Scheduling Algorithm acts like FCFS when there are equal priority processes. If two processes have the same priority, the process with the earlier arrival time will be executed first. So, we say Preemptive Priority is a special kind of FCFS Scheduling Algorithm.

Difference between FCFS and Preemptive Priority Scheduling Algorithm :

S.NO. FIRST COME FIRST SERVE PREEMPTIVE PRIORITY
1. It executes processes in the same sequence as they enter the ready queue. It executes those processes first that have the highest priortiy.
2. It is a non preemptive process. It is a preemptive process.
3. It is the simple most process of all. It is more complicated to implement.
4. The response and waiting time of the processes that come later increase a lot. It is more effective as the response time and waiting time of the processes decrease significantly.
5. The processes that enter the ready queue last have to wait the most. If the processes at the beginning have a large burst time then the whole system gets delayed. The processes with the lowest priority have to wait the most. They are executed very late even though their burst times may be very small.
6. FCFS acts as a Preemptive Priority Scheduling Algorithm where earlier arrival time has higher priority. Preemptive Priority Scheduling Algorithm acts like FCFS when there are equal priority processes.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up