【问题标题】:How does multilevel feedback queue scheduling works?多级反馈队列调度如何工作?
【发布时间】:2017-04-29 01:48:01
【问题描述】:

我一直在阅读 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

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

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

 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

我一头雾水,网上的视频一点用都没有。

【问题讨论】:

    标签: operating-system queue scheduling


    【解决方案1】:

    我认为您误解了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 在 time=0(即系统启动后 0 毫秒)到达,因此它进入就绪队列 Q1 并立即开始在处理器上运行。 5 毫秒后,它被抢占并移至 Q2,等待运行剩余的 3 毫秒。此时(系统启动后 5 毫秒)P2 已经到达,它正在 Q1 中等待。所以,它开始运行。在 6 ms P3 到达 Q1。因此,在系统启动后 7 毫秒:P1 在 Q2 等待,还剩 3 毫秒。 P2 仍在运行,还剩 5 毫秒。而 P3 正在 Q1 等待。

    【讨论】:

    • 解释得很漂亮,正是我所需要的。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2020-09-12
    • 2018-12-29
    • 2020-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多