Linux Posix Timer?????????
???????????? ???????[ 2014/2/25 13:41:01 ] ?????????????? linux ???? ???????
???????????????????????????????????????????????????????
??????????????
????int timer_settime(timer_t timer_id?? int flags?? struct itimerspec* new_setting?? struct itimerspec* old_setting);
????????timer_id??timer_create?????????id???
????????flags?TIMER_ABSTIME????0?????????????????????????
????????new_setting?????????????????
????????old_setting????????????3?????????????????
????timer_setting???????????
????CLOCK_DISPATCH(timr->it_clock?? timer_set?? (timr?? flags?? &new_spec?? rtn));
?????????ú?????????????common_timer_set??
????int common_timer_set(struct k_itimer *timr?? int flags??
????struct itimerspec *new_setting?? struct itimerspec *old_setting)
????common_timer_set?У???????timr?????а?????hrtimer(struct k_itimer:: it.real.timer)?????hrtimer????????????????????hrtimer???????????????posix_timer_fn??
static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)
??????
// ??????????????????????ε???????
if (timr->it.real.interval.tv64 != 0)
si_private = ++timr->it_requeue_pending;
// ????posix_timer_event??????????????
// ???????????????SIGEV_NONE??????????????posix_timer_event?????? // ??0??????????????????y??????????????????????????? // HRTIMER_RESTART???hrtimer???????????????
if (posix_timer_event(timr?? si_private))
if (timr->it.real.interval.tv64 != 0)
hrtimer_forward (timer?? now?? timr->it.real.interval);
ret = HRTIMER_RESTART;
?????????????????SIGEV_NONE??????????posix_timer_event???????????????????????????????????????????signal?????????С?
????posix_timer_event??????????????sigqueue????????????????sigpending??Linux??signal????????С?
int posix_timer_event(struct k_itimer *timr?? int si_private)
????
imr->sigq->info.si_code = SI_TIMER; // SI_TIMER???????????????
??????
if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
struct task_struct *leader;
// ?????????????????0????????????
int ret = send_sigqueue(timr->sigq?? timr->it_process?? 0);
if (likely(ret >= 0)) // ???????????????????????????????????
return ret;
timr->it_sigev_notify = SIGEV_SIGNAL;
leader = timr->it_process->group_leader;
put_task_struct(timr->it_process);
timr->it_process = leader;
}
// ???????????????????????1??
return send_sigqueue(timr->sigq?? timr->it_process?? 1);
send_sigqueue??Linux??signal????????????????ú??????????С?????timer????
// ?????????ж???????????????????sigpending?????У???????????????? // ?γ??????д????????ζ????????????ε???????????sigqueue?? // si_overrun???λ??????????????????????????????sigqueue
if (unlikely(!list_empty(&q->list))) {
/*
* If an SI_TIMER entry is already queue just increment
* the overrun count.
*/
BUG_ON(q->info.si_code != SI_TIMER);
q->info.si_overrun++;
goto out;
}
q->info.si_overrun = 0;
// ??sigqueue????sigpending????
??????
out:
unlock_task_sighand(t?? &flags);
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11