1. 最长工作优先(LJF):
它是 CPU 调度算法,其中具有最大突发行的进程首先执行。一旦进程进入就绪队列,则该进程只有在执行完成后才退出,因此它是一个非抢占式进程。如果进程的突发次数相同,则选择总体时间最短的作业。这种CPU调度算法导致系统吞吐量低。
Process | AT | BT |
---|---|---|
1 | 0 | 3 |
2 | 1 | 2 |
3 | 2 | 4 |
4 | 3 | 5 |
5 | 4 | 6 |
2. 最长剩余工作优先(LRJF):
它是最长作业优先 CPU 调度算法的抢占式版本。每秒选择一次处理突发时间,然后选择最长的作业。如果进程的突发时间相同,则选择总体到达时间较短的作业。
它遭受饥饿,因为同时检查进程的剩余突发时间。它也被称为“最长剩余时间优先”算法。
Process | AT | BT |
---|---|---|
1 | 0 | 3 |
2 | 1 | 2 |
3 | 2 | 4 |
4 | 3 | 5 |
5 | 4 | 6 |
LJF和LRJF CPU调度算法的区别:
LJF | LRJF |
---|---|
Non preemptive | Preemptive |
It suffers from starvation | It also suffers from starvation |
Waiting Time is high | Waiting Time is not so high, and processes get chances for execution after some interval. |
Switching context is less, since a process that once enters running state is executed completely. | Switching context is more, since the process are continually checked for execution. |
The processes are executed based on their CPU time and arrival time alone, without increasing CPU overload. | The processes are repeatedly checking for an idle CPU, thereby increasing the overload. |
No process can complete its execution until longest job persists. | The processes can complete execution before the longest process. |