📜  SRJF和LRJF CPU调度算法的区别

📅  最后修改于: 2022-05-13 01:56:11.443000             🧑  作者: Mango

SRJF和LRJF CPU调度算法的区别

1.最短剩余工作优先(SRJF)
最短剩余作业优先也称为最短剩余时间优先,是最短作业优先调度算法的抢占式版本。
在剩余的最短作业优先,以最小的运行过程中完成(即剩余时间)定于下一次运行,在SRJF,正在运行的进程将被告知是否一个新的进程的CPU调度程序需要更少的突发时间到达抢占执行。

2.最长剩余工作优先(LRJF)
最长剩余作业优先也称为最长剩余时间优先,与SRJF正好相反。在这种类型的CPU调度中,处理时间最长的进程被调度到下一个运行,如果有更长的突发时间的新进程进入队列,则正在运行的进程将被抢占。

差异表:

Shortest Remaining Job First (SRJF)Longest Remaining Job First(LRJF)
short processes are executed first and at 
any instant if a process with shorter time 
arrives it will be executed first. 
 
Long processes are executed first and at 
any instant of time if a long process 
appears it will be executed first.
It does not have large average turn around 
time therefore it is more effective than LFJT 
 
It has a very large average turn around 
time and waiting time therefore 
reduces the effectiveness of the 
operating system 
 
It does not lead to convoy effectIt will lead to convoy effect.
More process are executed in less amount of timeLess process are executed in certain amount of time

让我们为每个解决一个问题:



LJFT :

ProcessesArrival TimeBurst Time
P102
P204
P308

最长剩余工作优先:
甘特图:

因此,决赛桌将是:

LJFT :



ProcessesArrival TimeBurst TimeCompletion TimeTurn Around TimeWating Time
P102121210
P20413139
P30814146

Turn around time = Completion time - Arrival time 

Average turn around time, 
= [(12-0) + (13-0) + (14-0)]/3
= (12 + 13 + 14)/3
= 13


Waiting time = Turn around time - Burst time

Average waiting time,
= [(12-2) + (13-4) + (14-8)]/3
= (10 + 9 + 6)/3
= 8.34 

问题二:

LJFT

LJFT

ProcessesArrival TimeBurst Time
P1020
P21525
P33010
P44515

最短剩余时间优先:
甘特图:

因此,决赛桌将是:

SRFT

ProcessesArrival TimeBurst TimeCompletion TimeTurn Around TimeWating Time
P102020200
P21525554015
P3301040100
P44515702510

Turn around time = Completion time - Arrival time 

Average turn around time, 
= [(20-0) + (55-15) + (40-10) + (70-45)]/4
= (20 + 40 + 30 + 25)/4
= 28.75


Waiting time = Turn around time - Burst time

Average waiting time,     
= [(20-20) + (40-25) + (10-10) + (25-15)] / 4
= (0 + 15 + 0 + 10) / 4
= 6.25