如何判断系统支持hrtimer

如何判断系统支持hrtimer
2011-12-01 10:37

Here are several ways you can identify if your system supports high resolution timers.

  • Examine kernel startup messages

Watch the kernel boot messages, or use dmesg. If the kernel successfully turns on the high resolution timer feature, it will print the message "Switched to high resolution mode on CPU0" (or something similar) during startup.

  • Examine /proc/timer_list

You can also examine the timer_list, and see whether specific clocks are listed as supporting high resolution. Here is a dump of /proc/timer_list on an OSK (ARM-based) development board, showing the clocks configured for high resolution.

    • cat /proc/timer_list
Timer List Version: v0.3HRTIMER_MAX_CLOCK_BASES: 2now at 294115539550 nsecscpu: 0 clock 0:  .index:      0  .resolution: 1 nsecs  .get_time:   ktime_get_real  .offset:     0 nsecsactive timers: clock 1:  .index:      1  .resolution: 1 nsecs  .get_time:   ktime_get  .offset:     0 nsecsactive timers: #0: <c1e39e38>, tick_sched_timer, S:01, tick_nohz_restart_sched_tick, swapper/0 # expires at 294117187500 nsecs [in 1647950 nsecs] #1: <c1e39e38>, it_real_fn, S:01, do_setitimer, syslogd/796 # expires at 1207087219238 nsecs [in 912971679688 nsecs]  .expires_next   : 294117187500 nsecs  .hres_active    : 1  .nr_events      : 1635  .nohz_mode      : 2  .idle_tick      : 294078125000 nsecs  .tick_stopped   : 0  .idle_jiffies   : 4294966537  .idle_calls     : 2798  .idle_sleeps    : 1031  .idle_entrytime : 294105407714 nsecs  .idle_sleeptime : 286135498094 nsecs  .last_jiffies   : 4294966541  .next_jiffies   : 4294966555  .idle_expires   : 294179687500 nsecsjiffies: 4294966542Tick Device: mode:     1Clock Event Device: 32k-timer max_delta_ns:   2147483647 min_delta_ns:   30517 mult:           140737 shift:          32 mode:           3 next_event:     294117187500 nsecs set_next_event: omap_32k_timer_set_next_event set_mode:       omap_32k_timer_set_mode event_handler:  hrtimer_interrupt

Here are some things to check:

1. Check the resolution reported for your clocks. If your clock supports high resolution, it will have a .resolution value of 1 nsecs. If it does not, then it will have a .resolution value that equals the number of nanoseconds in a jiffy (usually 10000 nsecs, on embedded platforms).

2. Check the event_handler for the Tick Device. If the event handlers is 'hrtimer_interrupt' then the clock is set up for high resolution handling. If the event handler is 'tick_handle_periodic', then the device is set up for regular tick-based handling.

3. Check the list of timers, and see if the attribute .hres_active has a value of 1. If so, then the high resolution timer feature is active.

  • Run a test program

You can run a small test program, and actually measure that the timers are returning in less than the period of a jiffy. If they are, this is the most definitive proof that your kernel supports high resolution timers. One example program you can try is cyclictest. Here is a sample command line which will test timers using nanosleep:

    • cyclictest -n -p 80 -i 500 -l 5000

This does a test of clock_nanosleep, with priority 80, at 500 microsecond intervals, running the 5000 iterations of the test.

from:http://elinux.org/High_Resolution_Timers


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值