📌  相关文章
📜  最长作业优先(LJF)与轮循(RR)调度算法之间的差异

📅  最后修改于: 2021-08-27 18:12:17             🧑  作者: Mango

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

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

笔记 –
如果两个进程的突发时间相同,则使用FCFS断开连接,即首先处理最先到达的进程。

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

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

该算法的主要优点是,所有进程都一个接一个地执行,这不会导致进程出现饥饿或等待进程等待很长时间才能执行。最长作业优先(LJF)和轮询(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.