Skip to content
Related Articles

Related Articles

Improve Article

Difference between First Come First Served (FCFS) and Longest Job First (LJF) CPU scheduling algorithms

  • Last Updated : 05 Jun, 2020

1.First Come First Served (FCFS) :
First Come First Served (FCFS) is the simplest type of algorithm. It is a non-preemptive algorithm i.e. the process cannot be interrupted once it starts executing. The FCFS is implemented with the help of a FIFO queue. The processes are put into the ready queue in the order of their arrival time. The process that arrives first becomes the head of the queue while the others that arrive after are added to the rear of the queue. In First Come First Served (FCFS) algorithm, the process that arrives first, is sent first for execution by the CPU when CPU is free.

The main disadvantage of this algorithm is that the average waiting time is often quite long. It also leads to the convoy effect. This results in lower device or CPU utilisation and lower efficiency.

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

2. Longest Job First (LJF) :
Longest Job First (LJF) is based upon the burst time of the process. The processes are put into the ready queue based on their burst times. In this algorithm, the process with the largest burst time is processed first. The burst time of only those processes is compared that are present or have arrived until that time. It is also non-preemptive in nature. Its preemptive version is called Longest Remaining Time First (LRTF) algorithm.

The major disadvantage of this algorithm is that it gives very high average waiting time and average turnaround time for a given set of processes and thus reduces the effectiveness of the system.

Note –
If two processes have same burst time then the tie is broken using FCFS, i.e., the process that arrived first is processed first.

The difference between First Come First Served (FCFS) and Longest Job First (LJF) scheduling algorithm are as follows:

First Come First Served (FCFS)Longest Job First (LJF)
First Come First Served (FCFS) executes the processes in the order in which they arrive i.e. the process that arrives first is executed first.Longest Job First (LJF) executes the processes based upon their burst time i.e. in descending order of their burst times.
FCFS is non preemptive in nature.LJF is also non-preemptive but its preemptive version is also there called Longest Remaining Time First (LRTF) algorithm.
FCFS results in quite long waiting time for the processes and thus increases average waiting time.The average waiting time and average turnaround time for given set of processes is very large.
FCFS algorithm is the easiest to implement in any system.The LJF algorithm is very difficult to implement.
A process may have to wait for quite long to get executed depending on the burst time of the processes that have arrived first.A short process may never get executed and the system may keep executing the longer processes. This may cause the user to feel that his work is not being done in case of multi user systems.
FCFS lead to lower device and CPU utilisation thereby decreasing the efficiency of the system.LJF leads to very low processing speed thereby reducing the effectiveness of the system due to large average waiting time and turnaround time.
FCFS results in minimal overhead.In case of LJF, elapsed time should be recorded, results in more overhead on the processor and thereby decreases the throughput of the system.

My Personal Notes arrow_drop_up
Recommended Articles
Page :