循环调度算法



再说一遍,用JAVA做一些调度算法,但问题是我在互联网上找到的所有例子都不能回答我的问题,所以我没有其他地方可以问,所以我发了这个帖子:

如果我有3的量子时间,并且处理:

Name - ArrivalTime - BurstTime
P0 - 0 - 5
P1 - 6 - 5
P2 - 6 - 9
P3 - 8 - 2

因此,我没有发现任何例子涵盖这一点,如果过程P1还没有到来,但量子结束了呢?所以P0在3毫秒内执行,还有2毫秒,量子已经结束,P1还没有到达。程序是等待P1,还是完成P0,仍有1ms的等待时间(直到P1到达)?

调度算法只调度等待运行的进程。

一种执行方式可能是:

T0 : Waiting Process = [P0] ; Executed Process = P0(1-2-3) 
T3 : Waiting Process = [P0] ; Executed Process = P0(4-5) => P0 finished
T5 : Waiting Process = [] ; Executed Process = Nothing
T6 : Waiting Process = [P1, P2] ; Executed Process = P1(1-2-3)
T9 : Waiting Process = [P2, P3, P1] ; Executed Process = P2(1-2-3)
T12 : Waiting Process = [P3, P1, P2] ; Executed Process = P3(1-2) => P3 finished
T14 : Waiting Process = [P1, P2] ; Executed Process = P1(4-5) => P1 finished
T16 : Waiting Process = [P2] ; Executed Process = P2(4-5-6)
T19 : Waiting Process = [P2] ; Executed Process = P2(7-8-9) => P2 finished

在T3上,只有P0在等待运行,因此它将在下一段时间内执行。

最新更新