Interrupts (Slideshow)¶
Interrupt Facts¶
Interrupt context is not scheduled
No sleeping API calls allowed
Not easily debugged
Not easy in general
No prioritization
But …
Threaded interrupt handlers
… thanks to
PREEMPT_RT
slowly being integrated in mainline
Interrupt Service Routine¶
#include <linux/interrupt.h>
irqreturn_t irq_handler(int irq, void *cookie) { ... }
irq
: the interrupt number that is activecookie
: opque pointer, given ascookie
when IRQ is requestedReturn value …
** irqreturn_t
values**
|
interrupt was not from this device or was not handled (shared interrupt?) |
|
|
interrupt was handled by this device |
important! (Else line may remain active) |
|
handler requests to wake the handler thread (for threaded interrupts) |
Requesting (and Releasing) Interrupts (1)¶
#include <linux/interrupt.h>
int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *cookie);
const void* free_irq(unsigned int irq, void *cookie);
irq
: the requested interrupt linehandler
: interrupt handler to attach toirq
flags
: a meaningful combination ofIRQF_SHARED
Multiple interrupts shared on same line
IRQF_TRIGGER_RISING
Edge triggered: rising
IRQF_TRIGGER_FALLING
Edge triggered: falling
IRQF_TRIGGER_HIGH
Level triggered: high
IRQF_TRIGGER_LOW
Level triggered: low
name
: shows up in/proc/interrupts
cookie
: echoed back into interrupt handler when called
Note
After successful call to request_irq()
line is hot
immediately