I was reading Linux device drivers, 3rd edition and don't completelyunderstand a part describing interrupt handlers. I would like to clarify:are the interrupt handlers in Linux nonpreemptible?are the interrupt handlers in Linux non-reentrant?I believe I understand the model of Top/Bottom halves quite well, andaccording to it the interrupts are disabled for as long as the TopHalfis being executed, thus the handler can't be re-entered, am I right?But what about high priority interrupts? Are they supported by vanilla Linux orspecific real-time extensions only? What happens if a low priority interruptis interrupted by high priority one?
re-entrency of interrupts in Linux
linux;kernel;interrupt
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.