Linux: hrtimer 用法
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
hrtimer = high res timer
内核为高精度定时器重新设计了一套软件架构,它可以为我们提供纳秒级的定时精度,以满足对精确时间有迫切需求的应用程序或内核驱动,例如多媒体应用,音频设备的驱动程序等等。以下的讨论用hrtimer(high resolution timer)表示高精度定时器。
#include <linux/hrtimer.h>
static struct hrtimer hrtimer;
//init
hrtimer_init(&hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hrtimer.function = timer_hr_interrupt;
//
static enum hrtimer_restart timer_hr_interrupt(struct hrtimer *timer)
{
do_something();
return HRTIMER_NORESTART;
}
void start_timer(void)
{
hrtimer_start(&hrtimer, ktime_set(0, first_time* NSEC_PER_USEC), HRTIMER_MODE_REL);
}
static void do_something(void)
{
// do something
...
//start next timer
hrtimer_start(&hrtimer, ktime_set(0, next_time* NSEC_PER_USEC), HRTIMER_MODE_REL);
}
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献2条内容
所有评论(0)