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

📅  最后修改于: 2021-09-12 11:31:35             🧑  作者: 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.