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_RTslowly 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 ascookiewhen 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 toirqflags: a meaningful combination ofIRQF_SHAREDMultiple interrupts shared on same line
IRQF_TRIGGER_RISINGEdge triggered: rising
IRQF_TRIGGER_FALLINGEdge triggered: falling
IRQF_TRIGGER_HIGHLevel triggered: high
IRQF_TRIGGER_LOWLevel triggered: low
name: shows up in/proc/interruptscookie: echoed back into interrupt handler when called
Note
After successful call to request_irq() line is hot
immediately