内核中的高分辨率定时? [英] high resolution timing in kernel?
问题描述
我正在编写一个内核模块,该模块要求以至少0.01ms的精度测量的0.1ms间隔调用函数. 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?
推荐答案
假定您正在运行的内核已启用Hi-Res计时器支持(这是构建时间配置选项),并且您具有合适的计时器硬件,可以提供引发此类中断所需的支持,您可以使用内核hrtimer API来根据需要注册计时器.
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.
这是hrtimer文档: http://www.mjmwired.net/kernel/Documentation/timers/hrtimers.txt
Here is the hrtimer documentation: http://www.mjmwired.net/kernel/Documentation/timers/hrtimers.txt
但是请记住,要真正获得如此规模的不间断响应,您很可能还需要应用和配置Linux RT(也称为PREEMPT_RT)补丁.
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.
您可以在此处了解更多信息: http://elinux.org/Real_Time
You can read more here: http://elinux.org/Real_Time
这篇关于内核中的高分辨率定时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!