2010年(83)
分类:
2010-08-10 11:11:54
1. 运行时需要建立 work_struct
INIT_WORK in workqueue is used above linux kerner version 2.5.41,it is very like tasklet in some distance,use the workqueue sample,it will be run at the appropriate time controlled by kernel.From 2.6.20 INIT_WORK only reccept two paremeter, not three paremeter.
/**************************************************************/
#include
#include
#include
#include
#include
static struct work_struct works;
char list[20];
static void intr_print(struct work_struct *work)
{
printk("\n%s\n", list);
}
static int intr_init(void)
{
strlcpy(list, "Hello world", 20);
INIT_WORK(&works, intr_print);
schedule_work(&works);
return 0;
}
static void intr_exit(void)
{
printk("intr_exit");
}
module_init(intr_init);
module_exit(intr_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("XX");
/***************************************************************/