码迷,mamicode.com
首页 > 系统相关 > 详细

关于linux hrtimer高精度定时器的使用注意事项

时间:2019-03-24 00:18:20      阅读:425      评论:0      收藏:0      [点我收藏+]

标签:.com   enqueue   ext   process   如何   type   51cto   log   val   

关于linux hrtimer高精度定时器的使用注意事项

需要注意:
由于hrtimer本身没有interval周期的概念,
如果要实现hrtimer的周期调用,
方法1) 超时函数,调用hrtimer_start(, tim,HRTIMER_MODE_REL);即把timer根据此tim超时时间插入到timer_base的队列中, 并返回HRTIMER_NORESTART
方法2) 超时函数,调用hrtimer_forward()或者hrtimer_forward_now(), 把hrtimer的_softexpires和timerqueue_node.expires往后退一个interval的时间,然后函数返回HRTIMER_RESTART。 此后由__run_hrtimer()调用enqueue_hrtimer()来自动重新插入到timer_base的队列中。

如果方法2)中,如果不调用hrtimer_forward()或者hrtimer_forward_now(), 而直接返回HRTIMER_RESTART,那么定时函数的超时周期就变成timer_base的resolution分辨率的周期来运行了,这样的resolution,频率太高。

技术图片

具体参见我的《如何编写linux设备驱动》视频课程:
https://edu.51cto.com/course/17132.html

另外我的相关培训视频请看:
欢迎观看我发布的各个课程: https://edu.51cto.com/lecturer/8896847.html

关于linux hrtimer高精度定时器的使用注意事项

标签:.com   enqueue   ext   process   如何   type   51cto   log   val   

原文地址:https://blog.51cto.com/8906847/2367980

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!