定时器使用:

#include <linux/module.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/timer.h>

#define SECOND_MAJOR 248

struct timer_list mt;

void mtimer_handler(struct timer_list*arg)
{
    printk("__%s__\n",__func__);
    mod_timer(&mt,jiffies + 10*HZ);
}

static int __init timer_init(void)
{   
//  init_timer(&mt);
//  init_timer(mt); 

    timer_setup(&mt,&mtimer_handler,0);
//  mt.function = mtimer_handler;
    mt.expires = jiffies + 10*HZ;

    add_timer(&mt);

    printk("[%s]\n",__func__);
    return 0;
}

module_init(timer_init);

static void __exit timer_exit(void)
{
    del_timer(&mt);
    printk("[%s]\n",__func__);

}

module_exit(timer_exit);

MODULE_AUTHOR("BW");
MODULE_LICENSE("GPL v2");

参考:

Linux内核定时器struct timer_list
https://www.cnblogs.com/Cqlismy/p/11838913.html

linux驱动之定时器的使用
https://www.cnblogs.com/hjj801006/p/4551378.html

linux下网卡链路状态检测方法
https://blog.csdn.net/wj31932/article/details/98087522

Linux驱动程序教程:如何编写简单的Linux设备驱动程序
https://blog.csdn.net/yeshennet/article/details/82290724

Linux驱动技术(七) _内核定时器与延迟工作
https://www.cnblogs.com/xiaojiang1025/p/6388604.html

定时器+工作队列 内核周期性任务的实现机制
https://blog.csdn.net/iteye_8149/article/details/82240560?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&utm_relevant_index=2

工作队列(workqueue) create_workqueue/schedule_work/queue_work
https://blog.csdn.net/angle_birds/article/details/8448070

[Linux]softirq,tasklet和workqueue
https://zhuanlan.zhihu.com/p/361409809

Linux-workqueue讲解
https://www.cnblogs.com/vedic/p/11069249.html

【Linux内幕】schedule_work基本流程
https://blog.csdn.net/u012503639/article/details/107933857

(linux)schedule_delayed_work()
https://www.cnblogs.com/yanghong-hnu/p/4671350.html

linux驱动之定时任务timer,队列queue,小任务tasklet机制及用法
https://blog.csdn.net/u013256018/article/details/47803941

标签: aosp

仅有一条评论

  1. 链接文字:Mr.Tlyer's Blog
    链接地址:https://ntnas.top:82/typecho
    链接描述:Just do IT!

添加新评论