再说一遍,在JAVA中做一些调度算法,但问题是我在互联网上找到的所有例子都没有回答我的问题,所以我没有其他地方可以问这个帖子了:
如果我的量子时间为3,则处理:
Name - ArrivalTime - BurstTime
P0 - 0 - 5
P1 - 6 - 5
P2 - 6 - 9
P3 - 8 - 2
所以我发现没有例子说明如果过程P1没有到达,但量子结束了怎么办?所以P0在3 ms内执行,还剩2ms,量子已经结束而P1还没有到达。程序是等待P1还是完成P0并且仍然等待1 ms(直到P1到达)?
答案 0 :(得分:2)
调度算法仅调度等待运行的进程。
一次执行可能是:
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正在等待运行,所以它将在下一段时间内执行。