📌  相关文章
📜  多级队列 (MLQ) 和多级反馈队列 (MLFQ) CPU 调度算法之间的区别

📅  最后修改于: 2021-09-27 15:35:07             🧑  作者: Mango

在多编程环境中,经常会出现多个进程同时竞争 CPU 资源的情况。如果只有一个 CPU 可用,则必须在下一个运行的进程之间做出选择。操作系统中负责选择进程的部分称为调度程序,它使用的算法称为调度算法。

多重编程的目标是最大限度地提高 CPU 利用率。建议使用周转时间、响应时间、等待时间、吞吐量等标准来判断调度算法。有许多 CPU 调度算法,其中两种是-

  1. 多级队列调度
  2. 多级反馈队列调度

多级队列(MLQ)和多级反馈队列(MLFQ)CPU调度算法的区别:

Multilevel queue scheduling (MLQ) Multilevel feedback queue scheduling (MLFQ)
It is queue scheduling algorithm in which ready queue is partitioned into several smaller queues and processes are assigned permanently into these queues. The processes are divided on basis of their intrinsic characteristics such as memory size, priority etc. In this algorithm, ready queue is partitioned into smaller queues on basis of CPU burst characteristics. The processes are not permanently allocated to one queue and are allowed to move between queues.
In this algorithm queue are classified into two groups, first containing background processes and second containing foreground processes. 
80% CPU time is given to foreground queue using Round Robin Algorithm and 20% time is given to background processes using First Come First Serve Algorithm. 
 
Here, queues are classified as higher priority queue and lower priority queues. If process takes longer time in execution it is moved to lower priority queue. 
Thus, this algorithm leaves I/O bound and interactive processes in higher priority queue. 
 
The priority is fixed in this algorithm. When all processes in one queue get executed completely then only processes in other queue are executed. 
Thus, starvation can occur. 
 
The priority for process is dynamic as process is allowed to move between queue. A process taking longer time in lower priority queue can be shifted to higher priority queue and vice versa. 
Thus, it prevents starvation. 
 
Since, processes do not move between queues, it has low scheduling overhead and is inflexible. Since, processes are allowed to move between queues, it has high scheduling overhead and is flexible.

1. 多级队列调度 (MLQ) 示例:
下面根据优先级顺序列出了具有五个队列的多级队列。

  1. 系统进程队列
  2. 交互式进程队列
  3. 交互式编辑流程队列
  4. 批处理队列
  5. 学生进程队列

在这里,所有队列都有自己的调度算法,并选择具有最高优先级的进程。然后它被抢占或非抢占地执行。低优先级队列中的进程不能被执行,直到更高的进程队列全部为空。

例如,如果批处理队列正在运行并且交互进程进入就绪状态,则批处理被抢占并允许交互进程执行。

2. 多级反馈队列调度 (MLFQ) 示例:
现在,让我们考虑具有三个队列的多级反馈队列。

  1. 时间为 8 毫秒的循环队列,例如 Q1。
  2. 时间为 16 毫秒的循环队列,例如 Q2。
  3. 先来先服务队列,比如 Q3。

现在,当进程进入 Q1 时,它被允许执行,如果它没有在 8 毫秒内完成,它将转移到 Q2 并接收 16 毫秒。如果它没有在 16 秒内完成,它再次被抢占到 Q3。以这种方式,在该方案中进行调度。