October 2017
Intermediate to advanced
586 pages
14h 8m
English
The tasklet deferring mechanism is most used in DMA, network, and block device drivers. Just try the following command in the kernel source:
grep -rn tasklet_schedule
Now, let's see how to implement such a mechanism in our interrupt handler:
struct my_data { int my_int_var; struct tasklet_struct the_tasklet; int dma_request; }; static void my_tasklet_work(unsigned long data) { /* Do what ever you want here */ } struct my_data *md = init_my_data; /* somewhere in the probe or init function */ [...] tasklet_init(&md->the_tasklet, my_tasklet_work, (unsigned long)md); [...] static irqreturn_t my_irq_handler(int irq, void *dev_id) { struct my_data *md = dev_id; /* Let's schedule our tasklet */ tasklet_schedule(&md.dma_tasklet); ...