#include
#include
#include
MODULE_LICENSE(“BSD”);
static void workqueue_handler(unsigned long data);
static void workqueue_do(void * data);
DECLARE_WORK(test_workqueue, workqueue_do);
static struct timer_list workqueue_timer;
static void workqueue_handler(unsigned long data)
{
schedule_work(&test_workqueue);
mod_timer(&workqueue_timer, jiffies + HZ);
}
static void workqueue_do(void * data)
{
printk(KERN_ALERT “workqueue is running\n”);
}
static int __init test_init(void)
{
printk(KERN_ALERT “workqueue init running.\n”);
init_timer(&workqueue_timer);
workqueue_timer.function = &workqueue_handler;
workqueue_timer.data = 0;
workqueue_timer.expires = jiffies + HZ;
add_timer(&workqueue_timer);
return 0;
}
static void __exit test_exit(void)
{
printk(KERN_ALERT “workqueue exit running.\n” );
del_timer_sync(&workqueue_timer);
}
module_init(test_init);
module_exit(test_exit);