#include
#include
#include
MODULE_LICENSE ( “BSD” );
static void tasklet_handler(unsigned long data);
static void tasklet_do(unsigned long data);
DECLARE_TASKLET(test_tasklet, tasklet_do, 0);
static struct timer_list tasklet_timer;
static void tasklet_handler(unsigned long data)
{
tasklet_schedule(&test_tasklet);
mod_timer(&tasklet_timer, jiffies + HZ);
}
static void tasklet_do(unsigned long data)
{
printk(KERN_ALERT “tasklet is running.\n”);
}
static int __init test_init(void)
{
printk(KERN_ALERT “tasklet init running.\n”);
init_timer(&tasklet_timer);
tasklet_timer.function = &tasklet_handler;
tasklet_timer.data = 0;
tasklet_timer.expires = jiffies + HZ;
add_timer(&tasklet_timer);
return 0 ;
}
static void __exit test_exit(void)
{
printk(KERN_ALERT “tasklet exit running.\n” );
del_timer_sync(&tasklet_timer);
}
module_init(test_init);
module_exit(test_exit);