CLOCK_THREAD_CPUTIME_ID:本线程到当前代码系统CPU花费的时间。 mode是时间的模式,可以是HRTIMER_MODE_ABS, 表示绝对时间, 也可以是HRTIMER_MODE_REL,表 示相对时间。hrtimer_start:启动定时器。tim是设定的到期时间,mode和hrtimer_init中的mode参数含义相同。hrtimer_forward_now: 修改到期时间为从现在开始之后的inte...
enum hrtimer_mode mode); which_clock可以是CLOCK_REALTIME、CLOCK_MONOTONIC、CLOCK_BOOTTIME中的一种,mode则可以是相对时间HRTIMER_MODE_REL,也可以是绝对时间HRTIMER_MODE_ABS。设定回调函数: timer.function = hr_callback; 如果定时器无需指定一个到期范围,可以在设定回调函数后直接使用hrtimer_start激活该定时器...
HRTIMER_MODE_REL = 0x1, /* 相对模式 */ HRTIMER_MODE_PINNED = 0x02, /* 和CPU绑定 */ HRTIMER_MODE_ABS_PINNED = 0x02, /* 第一种和第三种的结合 */ HRTIMER_MODE_REL_PINNED = 0x03, /* 第二种和第三种的结合 */ 启动定时器:hrtimer_start(struct hrtimer *timer, ktime_t tim, const...
}staticint__initmy_init(void){ktime_ttim;hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); timer.function = timer_handler; tim =ktime_set(1,0);//1shrtimer_start(&timer,tim,HRTIMER_MODE_REL);return0; }staticvoid__exitmy_exit(void){printk("%s entern", __func__);hrtimer_c...
- mode:表示hrtimer的类型,主要包括两种:HRTIMER_MODE_ABS、HRTIMER_MODE_REL,前者是绝对模式,对应于CLOCK_REALTIME时钟,后者是相对模式,对应于CLOCK_MONOTONIC。 hrtimer_start用于启动一个定时器 int hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)- timer:表示当前的定时器-...
(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); timer.function = timer_handler; tim = ktime_set(1,0); //1 s hrtimer_start(&timer,tim,HRTIMER_MODE_REL); return 0; } static void __exit my_exit(void) { printk("%s entern", __func__); hrtimer_cancel(&timer); } module_init(my_...
HRTIMER_MODE_REL = 0x01, /* 定时器到期时间是相对值 */ HRTIMER_MODE_PINNED = 0x02, /* 定时器需要绑定到某个CPU上 */ HRTIMER_MODE_SOFT = 0x04, /* 定时器是“软”的,即该定时器的回调函数在软中断上下文执行 */ HRTIMER_MODE_HARD = 0x08, /* 定时器是“硬”的,即该定时器的回调函数在...
HRTIMER_MODE_REL_PINNED = 0x03, /* 第二种和第三种的结合 */ */ void hrtimer_init(structhrtimer *timer,clockid_tclock_id,enumhrtimer_modemode); 3. 定时器启动 /* * 参数timer是hrtimer指针 * 参数tim是时间,可以使用ktime_set()函数设置时间, ...
ktime = ktime_set(1, 0); //启动定时器 hrtimer_start(&mc3xxx_bootcheck_kthread_timer, ktime, HRTIMER_MODE_REL); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39...
enum hrtimer_mode mode); which_clock可以是CLOCK_REALTIME、CLOCK_MONOTONIC、CLOCK_BOOTTIME中的一种,mode则可以是相对时间HRTIMER_MODE_REL,也可以是绝对时间HRTIMER_MODE_ABS。设定回调函数: [cpp]view plain copy timer.function = hr_callback; ...