1.优先级调度算法:
优先级调度算法根据进程的优先级执行进程。为每个进程分配一个优先级,并首先执行具有最高优先级的进程。可以在内部和外部定义优先级。内部优先级是由系统根据所需的资源数量,所需的时间等决定的,而外部优先级则取决于需要工作的时间或为完成的工作支付的金额或过程的重要性。优先级调度可以是抢占式的也可以是非抢占式的。
笔记 –
- 如果两个进程具有相同的优先级,则使用FCFS断开连接。
- 在抢占模式下,最高优先级进程的等待时间始终为零,而在非抢占模式下的等待时间可能不为零。
缺点:
主要问题是饥饿或无限期封锁。可能会发生这样的情况,即在进程流中,系统会继续执行高优先级进程,而永远不会执行低优先级进程。
2.最长的工作优先:
最长作业优先是一种非抢占式调度算法。该算法基于进程的突发时间。根据进程的突发时间,即按照突发时间的降序,将它们放入就绪队列。顾名思义,该算法基于以下事实:首先处理突发时间最大的进程。仅考虑那些在该时间之前已到达系统的进程的突发时间。它的抢占版本称为最长剩余时间优先(LRTF)算法。
笔记 –
如果两个进程的突发时间相同,则使用FCFS打破平局,即首先处理最先到达的进程。
缺点-
- 对于给定的一组过程,该算法提供了很高的平均等待时间和平均周转时间。
- 这可能导致车队效应。
- 可能会发生一个短流程永远不会执行的情况,并且系统会继续执行较长的流程。
- 它降低了处理速度,从而降低了系统的效率和利用率。
最长作业优先(LJF)与优先级调度算法之间的区别如下:
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. |