In the interrupt mechanism in the kernel, in order to prevent the problem of resolving interrupt nesting (preventing one interrupt from interrupting another interrupt), introduce the small task mechanism:
Using a small task mechanism requires three steps:
First: Define a class of struct tasklet_struct;
The second step: Initialize the Taskelet will handle the function of the task and Takslet task bundle;
The third step: dispatch Tasklet:tasklet_schedule (&tasklet);
A#include <linux/delay.h> -#include <linux/clk.h> -#include <linux/miscdevice.h> the#include <linux/io.h> -#include <linux/ioport.h> -#include <asm/uaccess.h> - +#include <linux/gpio.h> -#include <mach/gpio.h> +#include <plat/gpio-cfg.h> A atModule_license ("GPL"); -Module_author ("Bunfly"); - - voidMy_tasklet_func (unsignedLongdata); - structtasklet_struct My_tasklet; - in intTest_init () - { toPrintk"Hello kernel\n"); +Tasklet_init (&my_tasklet,my_tasklet_func,0); -Tasklet_schedule (&My_tasklet); the return 0; * } $ Panax Notoginseng voidtest_exit () - { theTasklet_kill (&My_tasklet); +Printk"exit\n"); A } the +Module_init (test_init); -Module_exit (test_exit); $ $ voidMy_tasklet_func (unsignedLongdata) - { -Printk"Wang Wang wang\n"); the } -
Linux kernel Tasklet Small task mechanism