Kernel Re-Entrance vs Kernel pre-emption
来源:互联网 发布:佛山网络推广 编辑:程序博客网 时间:2024/04/27 13:35
Kernel Re-Entrance
If the kernel is not re-entrant, a process can only be suspended while it is in user mode. Although it could be suspended in kernel mode, that would still block kernel mode execution on all other processes. The reason for this is that all kernel threads share the same memory. If execution would jump between them arbitrarily, corruption might occur.
A re-entrant kernel enables processes (or, to be more precise, their corresponding kernel threads) to give away the CPU while in kernel mode. They do not hinder other processes from also entering kernel mode. A typical use case is IO wait. The process wants to read a file. It calls a kernel function for this. Inside the kernel function, the disk controller is asked for the data. Getting the data will take some time and the function is blocked during that time. With a re-entrant kernel, the scheduler will assign the CPU to another process (kernel thread) until an interrupt from the disk controller indicates that the data is available and our thread can be resumed. This process can still access IO (which needs kernel functions), like user input. The system stays responsive and CPU time waste due to IO wait is reduced.
This is pretty much standard for today's desktop operating systems.
Kernel pre-emption
Kernel pre-emption does not help in the overall throughput of the system. Instead, it seeks for better responsiveness.
The idea here is that normally kernel functions are only interrupted by hardware causes: Either external interrupts, or IO wait cases, where it voluntarily gives away control to the scheduler. A pre-emptive kernel instead also interrupts and suspends kernel functions just like it would interrupt processes in user mode. The system is more responsive, as processes e.g. handling mouse input, are woken up even while heavy work is done inside the kernel.
Pre-emption on kernel level makes things harder for the kernel developer: The kernel function cannot be suspended only voluntarily or by interrupt handlers (which are somewhat a controlled environment), but also by any other process due to the scheduler. Care has to be taken to e.g. avoid deadlocks: A thread locks resource A but needing resource B is interrupted by another thread which locks resource B, but then needs resource A.
- Kernel Re-Entrance vs Kernel pre-emption
- linux kernel bridge entrance
- "android linux kernel" VS "standard linux kernel"
- "android linux kernel" VS "standard linux kernel"
- Kernel
- kernel
- kernel
- kernel
- kernel
- kernel
- kernel
- Kernel
- kernel space vs user space
- 深入MTK平台bootloader启动之【 Pre-loader -> Lk -> kernel】
- Linux Kernel Security (SELinux vs AppArmor vs Grsecurity)
- /kernel/kernel.asm
- kernel/kernel.asm
- Issue: vmware tools pre-built modules not suitable for running kernel
- android快捷键
- Linux more 命令详解
- 被架构师渺杀之后。。。
- Java入门, 泛型编程
- MySQL的安装|如何安装MYSQL(图文)
- Kernel Re-Entrance vs Kernel pre-emption
- HDU 4302 Holedox Eating
- c++ c#结构体调用
- java中变量的初始化
- Android研究-linux内核启动到android系统
- 使用脚本编写 Vim 编辑器,第 1 部分: 变量、值和表达式
- 设计模式C++实现(1)——工厂模式
- ios 后台运行
- UIApplication深入研究