标签

1.
int timer_settime(timer_t timerid, int flags,
const struct itimerspec *restrict value,
struct itimerspec *restrict ovalue);
当flags为0时将会等待时间间隔后触发该timer
其他时(其实也就是TIMER_ABSTIME)则很快会触发

此外,
74 value.it_interval.tv_sec = 0;
75 value.it_interval.tv_nsec = 0;
76 value.it_value.tv_sec = 2;
77 value.it_value.tv_nsec = 0;
it_interval设置之后每个一段时间触发一次

2.
int timer_create(clockid_t clockid, struct sigevent *restrict evp,
timer_t *restrict timerid);
此函数可以在触发timer时加入自己的参数(sival_ptr)
sigevent为:
evp.sigev_notify = SIGEV_THREAD;
evp.sigev_notify_function = itms_alarm_handler;
evp.sigev_value.sival_ptr = s_;

或者

evp.sigev_notify = SIGEV_SIGNAL;
evp.sigev_signo = SIGALRM;
evp.sigev_value.sival_ptr = &pid;

Advertisements