📜  FCFS中的关系和抢占式优先级调度算法

📅  最后修改于: 2021-08-24 05:05:40             🧑  作者: Mango

在本文中,我们将了解FCFS如何成为一种特殊的优先级抢先式调度算法。另外,我们将彼此讨论这种关系。让我们一一讨论。

1.先来先服务(FCFS)调度算法:
FCFS是最简单的CPU调度算法,它执行最先出现的过程。这是一种非抢占式算法。首先进入就绪队列的进程将由CPU首先执行,然后是第二个,然后是第三个,依此类推。进程的到达时间是此处的决定因素。就绪队列的行为类似于FIFO(先进先出)队列。

例子 –
这是进程,它们的到达时间和突发时间的列表。甘特图显示了它们是如何执行的。

PROCESS ARRIVAL TIME BURST TIME
P1 0 10
P2 3 5
P3 5 2
P4 6 6
P5 8 4

随着进程进入就绪队列,它们将一一发送到要执行的CPU。除非第一个到达的进程完成执行,否则直到下一个都没有机会。

2.优先级优先调度算法:
在“抢先式优先级调度算法”中,进程附带有优先级。优先级数字越低,附加到进程的优先级越高。具有较高优先级的流程将优先于正在进行的流程。它获取CPU。优先级为1的进程始终在到达时就获得CPU,并且永远不会被抢占。它的响应时间为0。按照FCFS顺序安排优先级相同的进程。

例子 –
这是进程,它们的到达时间和突发时间的列表。甘特图显示了它们是如何执行的。

PROCESS ARRIVAL TIME BURST TIME PRIORITY
TOTAL REMAINING
P1 0 4 4 4
P2 1 3 3 3
P3 3 4 4 1
P4 6 2 2 5
P5 8 4 4 2

FCFS是一种特殊的抢占式优先级调度算法:
FCFS执行在就绪队列中首先出现的过程。这意味着它将优先级放在进程的到达时间上。首先出现的进程比其他进程具有更高的优先级,因此首先获取CPU。因此,我们说FCFS是一种特殊的抢占式优先级调度算法,其到达时间越早优先级越高。

抢占式优先级是一种特殊的FCFS调度算法:
当优先级进程相等时,抢占式优先级调度算法的行为类似于FCFS。如果两个进程具有相同的优先级,则将首先执行到达时间较早的进程。因此,我们说抢占式优先级是一种特殊的FCFS调度算法。

FCFS和抢占式优先级调度算法之间的区别:

S.NO. FIRST COME FIRST SERVE PREEMPTIVE PRIORITY
1. It executes processes in the same sequence as they enter the ready queue. It executes those processes first that have the highest priortiy.
2. It is a non preemptive process. It is a preemptive process.
3. It is the simple most process of all. It is more complicated to implement.
4. The response and waiting time of the processes that come later increase a lot. It is more effective as the response time and waiting time of the processes decrease significantly.
5. The processes that enter the ready queue last have to wait the most. If the processes at the beginning have a large burst time then the whole system gets delayed. The processes with the lowest priority have to wait the most. They are executed very late even though their burst times may be very small.
6. FCFS acts as a Preemptive Priority Scheduling Algorithm where earlier arrival time has higher priority. Preemptive Priority Scheduling Algorithm acts like FCFS when there are equal priority processes.