Linux Posix Timer?????????
???????????? ???????[ 2014/2/25 13:41:01 ] ?????????????? linux ???? ???????
????????????????Linux???POSIX?????????????????ж?posix???????????????kernelposix-timers.c/h?У??????????????2.6.29??????????????????POSIX?????????????man?????
????Linux????POSIX?????????????????????????????
int timer_create(clockid_t which_clock?? struct sigevent* timer_event_spec?? timer_t* created_timer_id);
int timer_gettime(timer_t timer_id?? struct itimerspec* setting);
int timer_settime(timer_t timer_id?? int flags?? struct itimerspec* new_setting?? struct itimerspec* old_setting);
int timer_delete(timer_t timer_id);
|
????????????????Щ????????????磺
clock_nanosleep
clock_getres
clock_settime
clock_gettime
timer_getoverrun
|
??????????????/??????????????????timer_create??
????int timer_create(clockid_t which_clock?? struct sigevent* timer_event_spec?? timer_t* created_timer_id);
????????which_clock????????????CLOCK_REALTIME??CLOCK_MONOTONIC????????????????clock??
????????timer_event_spec??????????????????????kernel?У?timer_event_spec??it_sigev_notify???????SIGEV_SIGNAL??SIGEV_NONE??SIGEV_THREAD_ID???????????????????????????????????SIGEV_THREAD??SIGEV_THREAD?????????POSIX????????????????????????www.linuxidc.com???????????includeasm-genericsiginfo.h??????????
/*
* sigevent definitions
*
* It seems likely that SIGEV_THREAD will have to be handled from
* userspace?? libpthread transmuting it to SIGEV_SIGNAL?? which the
* thread manager then catches and does the appropriate nonsense.
* However?? everything is written out here so as to not get lost.
*/
#define SIGEV_SIGNAL 0 /* notify via signal */
#define SIGEV_NONE 1 /* other notification: meaningless */
#define SIGEV_THREAD 2 /* deliver via thread creation */
#define SIGEV_THREAD_ID 4 /* deliver to thread */
|
????????SIGEV_THREAD_ID?????????POSIX??????ó??????????????á??????????
????????created_timer_id????????????????????????????
???????濴????????????????????
int timer_create(clockid_t which_clock?? struct sigevent* timer_event_spec?? timer_t* created_timer_id);
struct k_itimer * new_timer = alloc_posix_timer(); // ??????????????
?????? // ????idr??齫new_timer?????id?????????????????
// ?????COCK_DISPATCH?????????common_timer_create????
CLOCK_DISPATCH(which_clock?? timer_create?? (new_timer));
?????? // ??struct sigevent* timer_event_spec???浽new_timer????????У??????? // ????????????????
?????? // ??new_timer????struct task_struct::signal->posix_timers?С??????????? // ??it_sigev_notify???SIGEV_THREAD_ID?????task_struct?????????? // ????????????????task_struct??????????????
// posix_timers??????????task???????????????????????????????? // ???????????????????posix?????
common_timer_create?????????k_itimer?е?hrtimer??hrtimer??Linux?????????
static int common_timer_create(struct k_itimer *new_timer)
{
hrtimer_init(&new_timer->it.real.timer?? new_timer->it_clock?? 0);
return 0;
}
|
??????
???·???
??????????????????
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