1. 多级队列调度(MLQ):
只有一个队列并调度所有进程是相当困难的。这是使用多级队列调度的地方。在这种情况下,根据进程的属性(例如系统进程、I/O 进程等)将进程分为不同的类。因此我们得到 n 类进程的“n”个队列。每个队列都有一个优先级,可以使用自己的调度算法,方便同时使用多种调度算法。通常,队列的最高级别具有最高优先级,随着我们移动到较低级别而降低。如果上层具有相对于下层的绝对优先级,则它是不可抢占的,否则,如果时间片在各个队列之间划分,则它本质上是可抢占的。
- 优点 :
该算法的主要优点是我们可以在不同的队列中同时使用FCFS、SSJF、LJF等多种算法。 - 缺点:
最低级别的进程遭受饥饿问题。
2. 循环(RR):
它专为分时系统而设计。进程被放入就绪队列中,在这种情况下它是一个循环队列。在这种情况下,定义了一个称为时间量的小时间单位。该算法从队列中选择第一个进程并在时间片定义的时间内执行它。如果进程的突发时间小于时间片,则 CPU 执行下一个进程,但如果它的突发时间大于时间片,则该过程被中断,并在相同的时间片内执行下一个进程。如果进程被中断,则会发生上下文切换,并将进程放回队列的尾部。它本质上是先发制人的。
该算法主要依赖于时间量程。非常大的时间量使 RR 与 FCFS 相同,而非常小的时间量会导致开销,因为上下文切换将在非常小的间隔后一次又一次地发生。
该算法的主要优点是所有进程都一个接一个执行,这不会导致进程饥饿或进程等待很长时间才能执行。
MLQ 和 Round-Robin (RR) 调度算法的区别:
MLQ | Round-Robin (RR) |
---|---|
MLQ executes the process depending upon the priority if the level of queue in which the process resides and further execution is dependent upon the algorithm used in that level. | Round-Robin (RR) executes the processes based upon the time quantum defined i.e. each process is executed for a fixed amount of time. |
MLQ can be both non preemptive and preemptive depending upon the conditions. | Round-Robin (RR) is preemptive in nature. |
The average waiting time for given set of processes is dependent upon the tupe of algorithms used in various levels of multi level queue. | The average waiting time for given set of processes is quite small and depends on the time quantum. |
It is quite complex and difficult to implement. | It is quite easy to implement RR. |
It leads to the starvation of processes at the lower levels. | 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. |
Switching between different levels causes overhead on the processor. | 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. |