FOR FREE MATERIALS

Longest Remaining Time First (Preemptive LJF):

 

It is a preemptive version of Longest Job First.

 

Criteria: Burst Time + Arrival Time

Mode: Preemptive

Data Structure: Max Heap

 

 

Gantt Chart:

 

 

Number of Context Switching (CS) = 19 (Here time required for context switching is expensive) 

 

Now we calculate Turn Around Time (TAT) and Waiting Time (WT) using the following formula:

 

TAT = CT - AT, WT = TAT – BT 

And 

Response Time (RT) = FR (First Response) - AR (Arrival Time)

 

 

 

Advantages of LRTF

a.         It corrects some of the weaknesses of both SJF and FCFS.

 

b.         It tries to reduce overall turnaround time and maximize system utilization for 

            height system loads. 

 

Disadvantage

a.         Starvation of shorter job.

 

b.         Low response time among several jobs.

 

 

Question. (GATE 2006)

 

Consider three processes (process id 0,1,2 respectively) with compute time bursts 2,4 and 8 - time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id. The average turnaround time is:

(a) 13 units  

(b) 14 units 

(c) 15 unit  

(d) 16 unit

 

Answer:

 

As per question

 

 

Gantt Chart:

 

 

Now we calculate Turn Around Time (TAT) and Waiting Time (WT) using the following formula:

 

Turn Around Time = Completion Time - Arrival Time

 

 

CT = TAT because AT = 0 for all process

 

 

Option (a) correct.