# Difference between Longest Job First (LJF) and Round Robin (RR) scheduling algorithms

Last Updated : 16 Aug, 2022

1. 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. It may also lead to the convoy effect.

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.

2.Round-Robin (RR) : Round-Robin (RR) Scheduling Algorithm is particularly designed for time sharing systems. The processes are put into the ready queue which is a circular queue in this case. In this case a small unit of time known as time quantum is defined. The algorithm selects the first process from the queue and executes it for the time defined by the time quantum. If the process has burst time less than the time quantum then the CPU executes the next process but if it has burst time higher than the time quantum then the process is interrupted and next process is executed for same time quantum. If a process is interrupted then a context switch happens and the process is put back at the tail of the queue. It is preemptive in nature. This algorithm mainly depends on the time quantum. Very large time quantum makes RR same as the FCFS while a very small time quantum will lead to the overhead as context switch will happen again and again after very small intervals. The major advantage of this algorithm is that all processes get executed one after the other which does not lead to starvation of processes or waiting by process for quite long time to get executed.

The difference between Longest Job First (LJF) and Round-Robin (RR) scheduling algorithm are as follows: