#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);
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐