From what I read both are used to register interrupt handlers. I saw lots of request_irq
calls in kernel code but not even one __interrupt
call. Is __interrupt
some way to register a handler from user space?
The interrupt handler in the kernel executes several ISRs. The ISR handles the request event (a hardware or software interrupt), then sends it to the CPU, pausing the active process.
However, such kernel control paths may be arbitrarily nested; an interrupt handler may be interrupted by another interrupt handler, thus giving raise to a nested execution of kernel threads.
Stack machines, on the other hand, have no instruction execution pipeline, so only the address of the next instruction to be executed needs to be saved. This means that stack machines can treat an interrupt as a hardware generated procedure call.
An IRQ is an interrupt request from a device. Currently they can come in over a pin, or over a packet. Several devices may be connected to the same pin thus sharing an IRQ. An IRQ number is a kernel identifier used to talk about a hardware interrupt source.
request_irq
is essentially a wrapper call to request_threaded_irq
, which allocates the IRQ resources and enables the IRQ. That's paraphrased from the comment block in kernel/irq/manage.c
, Line #1239.
Basically, you want to use request_irq
if you need to setup interrupt handling for a device of some kind. Make sure that whatever subsystem you are working in doesn't already provide a wrapper for request_irq
, too. I.e., if you are working on a device driver, consider using the devm_*
family of calls to auto-manage the minutiae, like freeing unused variables and such. See devm_request_threaded_irq
at Line #29 in kernel/irq/devres.c
for a better explanation. Its equivalent call (and the one you would most likely use) is devm_request_irq
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With