HRTIMER_MODE_REL_PINNED_HARD = HRTIMER_MODE_REL_PINNED | HRTIMER_MODE_HARD, }; (3)hrtimer->function = xxx;通过hrtimer实例的function指定高精度定时器到期的回调函数; (4)hrtimer_start()/hrtimer_start_range_ns()开启定时器;如果定时器不需要指定到期范围就使用hrtimer_start(),如果定时器需要指定到期范...
hrtimer->function = watchdog_timer_fn; //设置时钟中断 watchdog_nmi_enable(cpu); //设置NMI(非屏蔽中断) hrtimer_start(hrtimer, ns_to_ktime(sample_period), HRTIMER_MODE_REL_PINNED); //启动时钟中断 } static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) { ... ... watch...
在struct hrtimer里面有一个node域,类型为struct rb_node,这个域代表了hrtimer在红黑树中的位置。 hrtimer_start hrtimer_start函数将一个hrtimer加入到一个按照到期时间排序的红黑树中,其主要流程为: int hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode); // 根据time和mode参...
hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update()); /* 设置到期时间为下一个jiffy时刻。*/ for (;;) { hrtimer_forward(&ts->sched_timer, now, tick_period); hrtimer_start_expires(&ts->sched_timer, HRTIMER_MODE_ABS_PINNED); /* Check, if the timer was already in the pa...
int hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode); // 根据time和mode参数的值计算hrtimer的超时时间,并设置到timer->expire域。 // expire设置的是绝对时间,所以如果参数mode的值为HRTIMER_MODE_REL(即参数tim的值为相对时间),那么需要将tim的值修正为绝对时间: ...
int hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)- timer:表示当前的定时器- tim:定时时间- mode:与hrtimer_init中的mode一样。 hrtimer_cancle应于取消一个定时器, 并等待其执行完毕 int hrtimer_cancel(struct hrtimer *timer) ...
1. struct hrtimer { 2. struct timerqueue_node node; 3. ktime_t _softexpires; 4. enum hrtimer_restart (*function)(struct hrtimer *); 5. struct hrtimer_clock_base *base; 6. long state; 7. ... 8. }; 1. 2. 3. 4. 5.
hrtimer层初始化在start_kernel() -> hrtimers_init()->hrtimers_prepare_cpu(0)中,首先初始化了cpu0的每cpu结构体hrtimer_cpu_base,用来管理当cpu0上所有的软件定时器。每个hrtimer_cpu_base根据4种时间类型和2种中断执行环境,分为8种clock_base来分别管理。2种中断执行环境是指定时器任务在硬中断上下文还是软...
hrtimer- >function=watchdog_timer_fn; hrtimer_start(hrtimer, ns_to_ktime(sample_period),HRTIMER_MODE_REL_PINNED); ...//Enable the perf event,启动前面创建的perfEvent,如果没有创建则进行创建if(watchdog_enabled & NMI_WATCHDOG_ENABLED)
("hrtimer handlern"); return HRTIMER_NORESTART; } static int __init my_init(void) { ktime_t tim; hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); timer.function = timer_handler; tim = ktime_set(1,0); //1s hrtimer_start(&timer,tim,HRTIMER_MODE_REL); return 0; } static...