📌  相关文章
📜  优先级调度和最长作业优先 (LJF) 之间的区别

📅  最后修改于: 2021-09-27 06:21:28             🧑  作者: Mango

1. 优先级调度算法:
优先级调度算法根据进程的优先级执行进程。每个进程都被分配一个优先级,优先级最高的进程首先被执行。可以在内部和外部定义优先级。内部优先级由系统根据所需资源的数量、所需时间等决定,而外部优先级基于需要工作的时间或为完成的工作支付的金额或流程的重要性。优先级调度可以是抢占式或非抢占式。

笔记 –

  • 如果两个进程具有相同的优先级,则使用 FCFS 打破平局。
  • 在抢占模式下,最高优先级进程的等待时间始终为零,而在非抢占模式下,它可能不为零。

缺点:
主要问题是饥饿或无限期阻塞。可能会发生在进程流中,系统一直执行高优先级进程而低优先级进程永远不会被执行的情况。

2. 最长的工作优先:
Longest Job First 是一种非抢占式调度算法。该算法基于进程的突发时间。根据它们的突发时间,即按照突发时间的降序将进程放入就绪队列。顾名思义,该算法基于这样一个事实,即首先处理具有最大突发时间的进程。只有那些在该时间之前已经到达系统的进程的突发时间才被考虑。它的抢占式版本称为最长剩余时间优先(LRTF)算法。

笔记 –
如果两个进程具有相同的突发时间,则使用 FCFS 打破平局,即首先处理最先到达的进程。
缺点-

  • 该算法为给定的一组进程提供了非常高的平均等待时间和平均周转时间。
  • 这可能会导致车队效应。
  • 可能会发生一个短进程可能永远不会被执行而系统继续执行较长进程的情况。
  • 它降低了处理速度,从而降低了系统的效率和利用率。

Longest job first (LJF) 和 Priority Scheduling 算法的区别如下:

Longest job first (LJF) Priority scheduling
Longest Job First (LJF) executes the processes based upon their burst time i.e. in descending order of their burst times. Priority scheduling executes the processes based upon their priorities i.e. in descending order of their priorities. A process with higher priority is executed first.
LJF is non-preemptive but its preemptive version is also there called Shortest Remaining Time First (SRTF) algorithm. Priority scheduling is both preemptive and non preemptive in nature.
The average waiting time for given set of processes is quite long which reduces the effectiveness of the system. There is no idea of average waiting time and response time.
A long process may never get executed and the system may keep executing the short processes. The problem of blocking of a process can be solved through aging which means to gradually increase the priority of a process after a fixed interval of time by a fixed number.