📌  相关文章
📜  先来先服务(FCFS)和最长作业优先(LJF)CPU调度算法之间的区别

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

1.先到先得(FCFS):
先来先服务(FCFS)是最简单的算法类型。这是一种非抢占式算法,即该流程一旦开始执行就无法中断。 FCFS是通过FIFO队列实现的。流程按到达时间的顺序放入就绪队列。首先到达的进程将成为队列的头,而其他随后到达的进程将被添加到队列的尾部。在先来先服务(FCFS)算法中,当CPU空闲时,首先到达的进程将首先发送给CPU执行。

该算法的主要缺点是平均等待时间通常很长。这也会导致车队效应。这导致较低的设备或CPU利用率以及较低的效率。

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

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

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

先来先服务(FCFS)和最长作业优先(LJF)调度算法之间的区别如下:

First Come First Served (FCFS) Longest Job First (LJF)
First Come First Served (FCFS) executes the processes in the order in which they arrive i.e. the process that arrives first is executed first. Longest Job First (LJF) executes the processes based upon their burst time i.e. in descending order of their burst times.
FCFS is non preemptive in nature. LJF is also non-preemptive but its preemptive version is also there called Longest Remaining Time First (LRTF) algorithm.
FCFS results in quite long waiting time for the processes and thus increases average waiting time. The average waiting time and average turnaround time for given set of processes is very large.
FCFS algorithm is the easiest to implement in any system. The LJF algorithm is very difficult to implement.
A process may have to wait for quite long to get executed depending on the burst time of the processes that have arrived first. A short process may never get executed and the system may keep executing the longer processes. This may cause the user to feel that his work is not being done in case of multi user systems.
FCFS lead to lower device and CPU utilisation thereby decreasing the efficiency of the system. LJF leads to very low processing speed thereby reducing the effectiveness of the system due to large average waiting time and turnaround time.
FCFS results in minimal overhead. In case of LJF, elapsed time should be recorded, results in more overhead on the processor and thereby decreases the throughput of the system.