×

Operating System Tutorial

Operating System Practice

LRTF: Longest Remaining Time First Scheduling Algorithm

In this tutorial, we will learn about the Longest Remaining Time First Scheduling Algorithm with the help of example. By Monika Sharma Last updated : May 06, 2023

What is Longest Remaining Time First Scheduling (LRTF) Algorithm?

LRTF, which stands for Longest Remaining Time First is a scheduling Algorithm used by the operating system to schedule the incoming processes so that they can be executed in a systematic way. This algorithm schedules those processes first which have the longest processing time remaining for completion. This algorithm can also be called as the preemptive version of the LJF scheduling algorithm. However, like the LJF, this algorithm is also not.

LRTF Algorithm Example

Let us take an example to understand it further.

Suppose there are three processes with process Id's P1, P2, P3, and P4, and they have the following details:

LRTF algorithm

Gant Chart

LRTF algorithm

Explanation

Each cell under the columns P1, P2, P3, and P4 denotes the remaining time required by that process for being completed.

LRTF algorithm

Note: Here, after all the process are left at the same time, then the execution order depends upon the arrival time. The process which has arrived first will be executed first in such cases.

Calculations

LRTF algorithm

Total Turn Around Time = 9 + 9 + 7 + 7
            = 32 milliseconds
Average Turn Around Time= Total Turn Around Time / Total No. of Processes
            = 32 / 4
            = 8 milliseconds

Total Waiting Time = 7 + 4 + 4 + 5
            = 20 milliseconds
Average Waiting Time = Total Waiting Time / Total No. of Processes
            = 20 / 4
            = 5 milliseconds

Note: It can be observed that in spite of having much less burst time of each process, the average waiting time and average turn-around time is much high.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.