📌  相关文章
📜  SJF 和 SRJF CPU 调度算法的区别

📅  最后修改于: 2021-09-27 15:02:16             🧑  作者: Mango

1.最短作业优先(SJF)
最短作业优先(SJF)是一种调度策略,它选择执行时间最短的等待进程下一个执行。它也称为下一个最短作业 (SJN) 或下一个最短进程 (SPN)。它是一种非抢占式调度算法。

2.最短剩余作业优先(SRTF)
Shortest Remaining Job First (SRJF) 是 SJF 调度的抢占式版本。在这种调度算法中,选择执行完成前剩余时间最少的进程。具有相同到达时间的进程会将 SRTF 转换为 SJF。

相似之处:

  • SJF 和 SRJF 实际上都不可行,因为无法预测过程的突发时间。
  • SJF 和 SRJF 都可能导致进程饥饿,因为如果连续添加短进程,长进程可能会被无限期推迟。
  • 一旦所有进程都在就绪队列中可用,则 SJF 和 SRJF 都被认为是相同的。这是因为进程加入就绪队列后,没有进行抢占。

区别:

Shortest Job First: Shortest Remaining Job First:
It is a non-preemptive algorithm. It is a preemptive algorithm.
It involves less overheads than SRJF. It involves more overheads than SJF.
It is slower in execution than SRJF. It is faster in execution than SJF.
It leads to comparatively lower throughput. It leads to increased throughput as execution time is less.
It minimizes the average waiting time for each process. It may or may not minimize the average waiting time for each process.
It may suffer from priority inversion. It may suffer from convoy effect.
It involves lesser number of context switching. It involves higher number of context switching.
Short processes are executed first and then followed by longer processes. Shorter processes run fast and longer processes show poor response time.