The second parameter of timerfd_settime ()?

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)

Mar.31,2022

timerfd man page

By default, the initial expiration time specified in new_value is interpreted relative to the current time on the timer's clock at the time of the call (i.e., new_value.it_value specifies a time relative to the current value of the clock specified by clockid).

new_value.it_value set the time of the initial timing

if timerfd_settime the second parameter is set to 0 , new_value.it_value is set to 1
if timerfd_settime the second parameter is set to TFD_TIMER_ABSTIME , new_value.it_value is set to now.tv_sec + 1

Menu