📌  相关文章
📜  多级队列调度 (MLQ) 和最短作业优先之间的区别

📅  最后修改于: 2021-09-12 11:08:38             🧑  作者: Mango

1. 多级队列调度(MLQ):
只有一个队列并调度所有进程是非常困难的。这是使用多级队列调度的地方。在这种情况下,根据进程的属性(例如系统进程、I/O 进程等)将进程分为不同的类。因此我们得到 n 类进程的“n”个队列。每个队列都有一个优先级,可以使用自己的调度算法,方便同时使用多种调度算法。通常,队列的最高级别具有最高优先级,随着我们移动到较低级别而降低。如果上层具有相对于下层的绝对优先级,则它是不可抢占的,否则,如果时间片在各个队列之间划分,则它本质上是可抢占的。

  • 好处 –
    该算法的主要优点是我们可以在不同的队列中同时使用FCFS、SSJF、LJF等多种算法。
  • 缺点——
    最低级别的进程遭受饥饿问题。

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

该算法的主要优点是它为给定的一组进程提供了最短的等待时间,从而减少了平均等待时间。该算法的缺点是系统可能永远不会处理长进程,并且可能会在队列中停留很长时间,导致进程饥饿。

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

SJF 和多级队列调度的区别:

Shortest Job First (SJF) Multi Level Queue Scheduling (MLQ)
SJF is also non-preemptive but its preemptive version is also there called Shortest Remaining Time First (SRTF) algorithm. MLQ can be non-preemptive or preemptive depending on the conditions.
It executes the processes in descending order of their burst time i.e. shortest job is executed first. Processes are executed depending on the priority of that particular level of queue to which the process belongs. Further selection of process is based upon the type of algorithm used in that particular queue.
The overhead in SJF is due to the fact that time elapsed has to be recorded. MLQ has some CPU overhead as it needs to switch between the queues.
Average waiting time is minimal in case of SJF. Average waiting time depends upon the algorithms used in various levels of queues.
The major difficulty in its implementation is that length of next CPU burst is unknown. It is complex algorithm and is difficult to implement.
It leads to starvation of processes which have very large burst times. It leads to the starvation of processes at lower levels.