📌  相关文章
📜  Longest Job First (LJF) 和 Round Robin (RR) 调度算法的区别

📅  最后修改于: 2021-09-11 06:23:06             🧑  作者: Mango

1. 最长工作优先(LJF):
最长作业优先 (LJF) 基于进程的突发时间。这些进程根据它们的突发时间被放入就绪队列。在该算法中,首先处理突发时间最大的进程。仅比较在该时间之前存在或已经到达的那些进程的突发时间。它本质上也是非抢占式的。它的抢占式版本称为最长剩余时间优先(LRTF)算法。

该算法的主要缺点是它为给定的一组进程提供了非常高的平均等待时间和平均周转时间,从而降低了系统的有效性。这也可能导致车队效应。

笔记 –
如果两个进程具有相同的突发时间,则使用 FCFS 打破平局,即首先处理最先到达的进程。

2.循环(RR):
循环 (RR) 调度算法是专门为分时系统设计的。进程被放入就绪队列中,在这种情况下它是一个循环队列。在这种情况下,定义了一个称为时间量的小时间单位。该算法从队列中选择第一个进程并在时间片定义的时间内执行它。如果进程的突发时间小于时间片,则 CPU 执行下一个进程,但如果它的突发时间大于时间片,则该过程被中断,并在相同的时间片内执行下一个进程。如果进程被中断,则会发生上下文切换,并将进程放回队列的尾部。它本质上是先发制人的。

该算法主要依赖于时间量程。非常大的时间量使 RR 与 FCFS 相同,而非常小的时间量会导致开销,因为上下文切换将在非常小的间隔后一次又一次地发生。

该算法的主要优点是所有进程都一个接一个地执行,这不会导致进程饥饿或进程等待很长时间才能执行。 Longest Job First(LJF)和Round-Robin(RR)调度算法的区别如下:

Longest Job First (LJF) Round-Robin (RR)
Longest Job First (LJF) executes the processes based upon their burst time i.e. in descending order of their burst times. Round-Robin (RR) executes the processes based upon the time quantum defined i.e. each process is executed for a fixed amount of time.
LJF is also non-preemptive but its preemptive version is also there called Longest Remaining Time First (LRTF) algorithm. Round-Robin (RR) is preemptive in nature.
The average waiting time and average turn-around time for given set of processes is very large. The average waiting time for given set of processes is quite small and depends on the time quantum.
The LJF algorithm is difficult to implement. It is quite easy to implement RR.
A short process may never get executed and the system may keep executing the longer processes and a user may feel that his work is being neglected in case of multi user systems. Each process is executed and every user feels that his work is being done as the CPU gives equal amount of time to each process.
In case of LJF, very large waiting time leads to slow processing and reduces the effectiveness of the system. In case of RR, if the time quantum is very small then context switch takes place again and again after very short intervals of time which leads to overhead.