#include<linux/sched.h>
#include<linux/interrupt.h>
#include<linux/kernel.h>
#include<linux/timer.h>
MODULE_LICENSE("Dual BSD/GPL");
#if 0
struct time_list{
unsigned long expires;
void (*funcation)(unsigned long)
unsigned long data;
};
#endif
struct timer_list my_timer;
void my_funcation(unsigned long data)
{
//mod_timer(&my_timer,jiffies+1*HZ);
printk("timer is coming...%d\n",data);
}
static int hello_init(void)
{
printk("init begin........\n");
unsigned int delay_sec = 1;
init_timer(&my_timer);
my_timer.expires = jiffies + delay_sec*HZ;
my_timer.data = delay_sec;
my_timer.function = my_funcation;
add_timer(&my_timer);
printk("int over...\n");
return 0;
}
static void hello_exit(void)
{
del_timer(&my_timer);
printk(KERN_ALERT"remove timer\n");
}
module_init(hello_init);
module_exit(hello_exit);
linux 定时器
最新推荐文章于 2024-04-12 08:24:35 发布