📜  FCFS与抢占优先级调度算法的关系

📅  最后修改于: 2021-09-27 22:44:58             🧑  作者: 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.