Longest Job First (LJF) is a non-preemptive scheduling algorithm. This algorithm is based on the burst time of the processes. The processes are put into the ready queue based on their burst times i.e., in descending order of the burst times. As the name suggests this algorithm is based on the fact that the process with the largest burst time is processed first. The burst time of only those processes is considered that have arrived in the system until that time. Its preemptive version is called Longest Remaining Time First (LRTF) algorithm.
Prerequisite: Process Management | CPU Scheduling
Advantages of Longest Job First(LJF)
Disadvantages of Longest Job First CPU Scheduling Algorithm
Let us consider the following examples.
Example 1: Consider the following table of arrival time and burst time for four processes P1, P2, P3 and P4.
The Longest Job First CPU Scheduling Algorithm will work on the basis of steps as mentioned below:
At time = 1, Available Process : P1. So, select P1 and start executing.
At time = 2,
At time = 3,
At time = 4,
At time = 5,
At time = 9,
At time = 17,
At time = 21,
Note –
CPU will be idle for 0 to 1 unit time since there is no process available in the given interval.
Gantt chart will be as following below:
Since, completion time (C.T) can be directly determined by Gantt chart, and
Turn Around Time (TAT)
= (Completion Time) – (Arrival Time)
Also, Waiting Time (WT)
= (Turn Around Time) – (Burst Time)
Therefore, final table
Output :
Total Turn Around Time = 44 ms
So, Average Turn Around Time = 44/5 = 8.8 ms
And, Total Waiting Time = 28 ms
So, Average Waiting Time = 28/5 = 5.6 ms
10 videos|99 docs|33 tests
|
|
Explore Courses for Computer Science Engineering (CSE) exam
|