多级反馈队列调度如何工作?

我一直在阅读Ritchie的“操作系统:结合UNIX和Windows”章节4.3关于调度。 我很难理解这种调度算法是如何工作的,因为我的测试与我的导师相矛盾。

以下是一个示例问题:2个多级反馈队列,1个CPU

-Time quantum is 5ms for both queues
-At time t=0 process P1(8ms) arrives
-At time t=2 process P2(7ms) arrives
-At time t=6 process P3(10ms) arrives

时间t = 7时进程,队列和CPU的最终状态是什么?

所以根据我的理解,这应该是结果。

 T0 => Q1(P1(8ms) Running), Q()
 T1 => Q1(), Q2(P1(3ms) Ready) *preemptively moved to Q2*
 T2 => Q1(P2(7ms) Running), Q2(P1(3ms) Ready)
 T3 => Q1(), Q2(P2(2ms) Ready, P1(3ms) Ready) *preemptively moved to Q2*
 T4 => Q1(), Q2(P2(2ms) Ready, P1(3ms) Running)
 T5 => Q1(), Q2(P2(2ms) Ready) *P1(3ms) executed for 3ms and terminated*
 T6 => Q1(P3(10ms), Ready), Q2(P2(2ms) Running)
 T7 => Q1(P3(10ms), Running), Q2() *P2(2ms) executed for 2ms and terminated*

但这个问题的答案如下:

在时间t = 7时:

-P1 has been executed for 5ms and it is in the READY state of the 2nd queue
-P2 has been executed for 2ms and it is in the RUNNING state
-P3 has arrived and it is in the READY state of the 1st queue

我很困惑,网上的视频根本没有帮助。


我认为你误解了什么time=7意味着什么。 你的计算表​​明你把它看作:“在7个时间间隔之后系统的状态会是什么?”

他们在这里问的是:“系统开始运行后7毫秒的状态会是什么?”

这个问题的答案是:

-P1 has been executed for 5ms and it is in the READY state of the 2nd queue
-P2 has been executed for 2ms and it is in the RUNNING state
-P3 has arrived and it is in the READY state of the 1st queue

说明:P1在时间= 0(即系统启动后0毫秒)到达,因此它进入就绪队列Q1并立即开始在处理器上运行。 5毫秒后,它被抢占并移动到Q2,在那里等待运行剩余的3毫秒。 此时(系统启动后5 ms),P2已经到达并且正在等待Q1。 所以,它开始运行。 在6 ms P3到达Q1。 所以,在系统启动7 ms后:P1正在等待Q2,剩下3 ms。 P2仍在运行5毫秒。 P3正在第一季度等待。

链接地址: http://www.djcxy.com/p/84837.html

上一篇: How does multilevel feedback queue scheduling works?

下一篇: Round Robin Scheduling Issue