Operating system 多级反馈队列调度是如何工作的?
我一直在读里奇的《操作系统:合并UNIX和Windows》第4.3章关于调度的内容。我很难理解这个调度算法是如何工作的,因为我的测试和我的导师有点矛盾 下面是一个示例问题: 2个多级反馈队列,1个CPUOperating system 多级反馈队列调度是如何工作的?,operating-system,queue,scheduling,Operating System,Queue,Scheduling,我一直在读里奇的《操作系统:合并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
-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
我很困惑,网上的视频一点帮助都没有。我想你误解了时间=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毫秒,P2已经到达,它正在Q1中等待。所以,它开始运行。6毫秒时,P3到达Q1。因此,在系统启动后7毫秒:P1在Q2等待,剩下3毫秒。P2仍在运行,剩余5毫秒。P3在Q1等待。很好地解释了这一点,这正是我所需要的。非常感谢你!