多级反馈队列调度是如何工作的?
How does multilevel feedback queue scheduling works?
我一直在阅读 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
我很困惑,网上的视频一点帮助都没有。
我认为您误解了 time=7
的意思。您的计算表明您将其视为:"What will the state of the system be after 7 intervals of time?"
他们在这里问的是:"What will the state of the system be 7 milliseconds after it started running?"
这个问题的答案是:
-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并立即在运行ning上启动处理器。 5 毫秒后,它被抢占并移动到 Q2,等待 运行 剩余的 3 毫秒。此时(系统启动后5ms)P2已经到达,正在Q1等待。所以,它开始 运行ning。在 6 ms P3 到达 Q1。因此,系统启动后 7 毫秒:P1 在 Q2 等待,还剩 3 毫秒。 P2 还剩 运行 5 毫秒。而P3在Q1等待
我一直在阅读 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
我很困惑,网上的视频一点帮助都没有。
我认为您误解了 time=7
的意思。您的计算表明您将其视为:"What will the state of the system be after 7 intervals of time?"
他们在这里问的是:"What will the state of the system be 7 milliseconds after it started running?"
这个问题的答案是:
-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并立即在运行ning上启动处理器。 5 毫秒后,它被抢占并移动到 Q2,等待 运行 剩余的 3 毫秒。此时(系统启动后5ms)P2已经到达,正在Q1等待。所以,它开始 运行ning。在 6 ms P3 到达 Q1。因此,系统启动后 7 毫秒:P1 在 Q2 等待,还剩 3 毫秒。 P2 还剩 运行 5 毫秒。而P3在Q1等待