I want to ask all of you. I want to use the timer under Linux timerfd
examples are as follows:
struct itimerspec new_value;
struct timespec now;
int ret = clock_gettime(CLOCK_REALTIME, &now);//
assert(ret != -1);
new_value.it_value.tv_sec = now.tv_sec + 1; //
new_value.it_value.tv_nsec = now.tv_nsec;
new_value.it_interval.tv_sec = 1; //
new_value.it_interval.tv_nsec = 0;
int timefd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK); //
assert(timefd != -1);
// ret = timerfd_settime(timefd, `0, &new_value, NULL);//
ret = timerfd_settime(timefd, TFD_TIMER_ABSTIME, &new_value, NULL);//
as in the example above, I want to create a relative timer with the parameter CLOCK_REALTIME
, which is used in both the clock_gettime
and timerfd_create
functions, and then should not be the corresponding relative timer in the timerfd_settime
function when the second parameter is 0
, but the timer is not triggered when epoll
is set to 0
. Instead, the timer works properly when the timerfd_settime
second parameter is set to TFD_TIMER_ABSTIME
(shouldn"t this parameter correspond to absolute time)