Linux - 嵌套中断

标签 linux interrupt interrupt-handling

<分区>

Linux 是否使用嵌套中断?

我的意思是,例如,当从任何设备服务中断时,可以允许在此例程中进一步中断吗?或者涉及上半部分和下半部分?

编辑:

如果 Linux 使用嵌套中断,如何关心它们的堆栈?

最佳答案

是的,Linux 中断是可重入的。 https://unix.stackexchange.com/a/7172/40346

The Linux kernel is reentrant (like all UNIX ones), which simply means that multiple processes can be executed by the CPU. He doesn't have to wait till a disk access read is handled by the deadly slow HDD controller, the CPU can process some other stuff until the disk access is finished (which itself will trigger an interrupt if so).

Generally, an interrupt can be interrupted by an other interrupt (preemption), that's called 'Nested Execution'. Depending on the architecture, there are still some critical functions which have to run without interruption (non-preemptive) by completely disabling interrupts. On x86, these are some time relevant functions (time.c, hpet.c) and some xen stuff.

There are only two priority levels concerning interrupts: 'enable all interrupts' or 'disable all interrupts', so I guess your "high priority interrupt" is the second one. This is the only behavior the Linux kernel knows concerning interrupt priorities and has nothing to do with real-time extensions.

If an interruptible interrupt (your "low priority interrupt") gets interrupted by an other interrupt ("high" or "low"), the kernel saves the old execution code of the interrupted interrupt and starts to process the new interrupt. This "nesting" can happen multiple times and thus can create multiple levels of interrupted interrupts. Afterwards, the kernel reloads the saved code from the old interrupt and tries to finish the old one.

关于Linux - 嵌套中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34527763/

相关文章:

linux - 如何为用户清除 linux 机器上的缓存内存?

arrays - 访问 'cat' 输出作为 'bash' 中的数组

linux - 让用户将文件从 Qt 的 ListView 中拖放到他们想要的位置

linux - 包含 for...in 循环的 Bash 脚本

c - 为什么 Linux 内核不会在返回 IRQ_HANDLED 的共享 IRQ 的第一个处理程序处停止?

x86 - (写内核)如何修改中断描述符表?

assembly - iretq 抛出 GP 错误

assembly - 如何在 BIOS 级汇编中打印换行符?

c - 为什么我不能从某些处理器异常中返回?玩具内核开发

C - 从内核模块写入物理内存