了解最短的作业优先算法(非抢先) [英] Understanding the Shortest Job First Algorithm (Non-preemptive)
问题描述
最短的作业优先算法如下图所示:
The shortest job first algorithm is shown in the following image:
如果首先是最短的作业/接下来是最短的流程,则顺序不应为:
P1→P5→P3→P4→P2?因为这是最低到最高服务时间的顺序.
为什么进程2排第二?
If it is shortest job first/shortest process next, shouldn't the order be:
P1 → P5 → P3 → P4 → P2 ? Since that's the order of lowest to highest service times.
Why does process 2 come second?
我知道我们是否使用突发时间,这就是顺序,但是我不知道服务时间和突发时间之间有什么区别.
I know if we use burst times instead, that would be the order, but I have no idea what the differences between service time and burst times are.
任何帮助解释该图形的人将不胜感激.
Any help would be much appreciated explaining that graphic.
推荐答案
问题中的图像遵循正确的顺序,即:
The image in the question follows the correct order which is:
P1→P2→P5→P3→P4
P1 → P2 → P5 → P3 → P4
说明:
P1
到达time = 0
,因此将首先执行它.此过程的服务时间为3
.因此,此过程在time=3
处完成.
Explanation:
P1
is arrived at time = 0
, so it will be executed first. Service Time of this process is 3
. So this process is completed at time=3
.
在time=3
,只有一个到达的进程是P2
.所有其他进程将在稍后到达.因此,此过程现在已执行.此过程的服务时间为6
,因此该过程在time=3+6=9
处完成.
At time=3
, there is only one process that is arrived which is P2
. All other processes arrive later. So this process is now executed. Service time of this process is 6
, so this process is completed at time=3+6=9
.
现在在time=9
,有三个过程分别是P3
,P4
和P5
(分别到达time= 4, 6 and 8
).由于P5
的服务时间是2
,与P3
和P4
的服务时间相比是最短的,因此现在执行P5
并在time=9+2=11
处完成.
Now at time=9
, there are three processes which are P3
, P4
and P5
(which arrived at time= 4, 6 and 8
respectively). Since the service time of P5
is 2
which is minimum as compared to that of P3
and P4
, so P5
is now executed and it gets completed at time=9+2=11
.
在time=11
,我们有两个进程,分别是P3
和P4
(分别到达time= 4 and 6
).由于P3
的服务时间是4
,比P4
的服务时间短,因此P4
现在被执行,并在time= 11+4=15
At time=11
, we have two processes which are P3
and P4
(which are arrived at time= 4 and 6
respectively). Since the service time of P3
is 4
which is less as compared to that of P4
, so P4
is executed now and it gets completed at time= 11+4=15
在time=15
,我们只有一个进程,即P4
.这样就可以执行了.由于此过程的服务时间为5
,因此它在time = 15+5 = 20
At time=15
, we have only one process which is P4
. So it is executed now. Since service time of this process is 5
, so it gets completed at time = 15+5 = 20
这篇关于了解最短的作业优先算法(非抢先)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!