#include <linux/timer.h>
#include <linux/module.h>
struct timer_list timer;
static void timer_test_handle(unsigned long data)
{
printk("timer test\n");
timer.expires = jiffies + HZ; // 1s
add_timer(&timer);
}
static int __init timer_test_init(void)
{
printk("timer test start\n");
int ret = 0;
init_timer(&timer);
timer.expires = jiffies + 50 * HZ;
timer.function = timer_test_handle;
add_timer(&timer);
return ret;
}
module_init(timer_test_init);
linux内核定时器-简单示例代码
最新推荐文章于 2024-06-30 17:00:00 发布