📜  操作系统中抢占式和非抢占式内核的区别

📅  最后修改于: 2021-09-12 11:07:04             🧑  作者: Mango

1.抢占式内核:
抢占式内核,顾名思义,是一种内核,它始终执行准备运行的最高优先级任务。它不能使用不可重入函数,除非和直到函数是互斥的。

示例: Linux 2-6

2. 非抢占式内核:
非抢占式内核,顾名思义,是一种内核,它没有内核数据结构上的竞争条件,因为一次只有一个进程在内核中处于活动状态。它被认为是实时应用程序的一个严重缺陷,因为它不允许抢占在内核模式下运行的进程。

示例: Linux 2.4

操作系统中抢占式和非抢占式内核的区别:

Preemptive Kernel 

 Non-Preemptive Kernel 

It is a process that might be replaced immediately.  It is a process that continuous to run until it finishes handling execution handler or voluntarily relinquishes CPU. 
It is more suitable for real time programming as compared to non-preemptive kernels.   It is less suitable for real-time programming as compared to preemptive kernel.  
In this, higher priority task that are ready to run is given CPU control.   In this, each and every task are explicitly given up CPU control.  
It generally allows preemption even in kernel mode.   It generally does not allow preemption of process running in kernel mode.  
Responsive time is deterministic and is more responsive as compared to non-preemptive kernel. Response time is nondeterministic and is less responsive as compared to preemptive kernel.
Higher priority task becomes ready, currently running task is suspended and moved to ready queue. Higher priority task might have to wait for long time.  
It does not require semaphores.   Shared data generally requires semaphores.  
It cannot use non-reentrant code.   It can use non-reentrant code.  
It is more difficult to design preemptive kernels as compared to non-preemptive kernel. It is less difficult to design non-preemptive kernels as compared to preemptive kernels.  
They are more secure and more useful in real-world scenarios.   They are less secure and less useful in real-world scenarios.