内核中的高分辨率计时?
我正在编写一个内核模块,需要以 0.1 毫秒的间隔调用函数,测量精度至少为 0.01 毫秒。 250MHz ARM CPU,HZ 变量(每秒 jiffies)为 100,因此任何基于 jiffies 的东西都是不行的,除非我可以增加 jiffies 粒度。
有什么建议/如何查看吗?
I'm writing a kernel module that requires function called in 0.1ms intervals measured with at least 0.01ms precision. 250MHz ARM CPU, the HZ variable (jiffies per second) is 100 so anything jiffies-based is a no-go unless I can increase jiffies granularity.
Any suggestions where/how to look?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您正在运行的内核已打开高分辨率计时器支持(它是构建时配置选项),并且您有一个适当的计时器硬件,可以提供所需的支持以引发如此粒度的中断,您可以使用在内核 hrtimer API 中根据您的要求注册计时器。
这是 hrtimer 文档: http://www.mjmwired.net/kernel/Documentation /timers/hrtimers.txt
但请记住,为了真正获得如此规模的不间断响应,您很可能还需要应用和配置 Linux RT(又名PREEMPT_RT)补丁。
您可以在这里阅读更多内容:http://elinux.org/Real_Time
Assuming the kernel you are running has the Hi-Res timer support turned on (it is a build time config option) and that you have a proper timer hardware which can provide the needed support to raise an interrupt in such granularity, you can use the in kernel hrtimer API to register a timer with your requirement.
Here is the hrtimer documentation: http://www.mjmwired.net/kernel/Documentation/timers/hrtimers.txt
Bare in mind though, that for truly getting uninterrupted responses on such a scale you most probably also need to apply and configure the Linux RT (aka PREEMPT_RT) patches.
You can read more here: http://elinux.org/Real_Time