Reputation: 83
I have to be missing something. I can obtain CLOCK_TAI using clock_gettime. However, when I attempt to use CLOCK_TAI with a pthread condition I get an EINVAL.
#include <pthread.h>
#include <stdio.h>
int main()
{
clockid_t clockTai = 11;
pthread_cond_t condition;
pthread_condattr_t eventConditionAttributes;
pthread_condattr_init( &eventConditionAttributes );
int ret = pthread_condattr_setclock( &eventConditionAttributes, clockTai );
printf( "%d %d\n", ret, clockTai );
pthread_cond_init( &condition,
&eventConditionAttributes );
return( 0 );
}
When compiled as follows it produces the following output:
g++ -o taiTest taiTest.cxx -lpthread -lrt
./taitest$ ./taiTest
22 11
Where EINVAL = 22 and CLOCK_TAI = 11.
This happens on both my Ubuntu 14.04 system and my embedded ARM device with an OS built from Yocto.
Any thoughts or help here are greatly appreciated. Thanks in advance.
Upvotes: 1
Views: 168
Reputation: 633
As per manual page, pthread_condattr_setclock()
accepts only a limited set of clock id values. CLOCK_TAI
is not one of them. The manual page talks about system clock which does sound somewhat ambiguous. CLOCK_REALTIME
, CLOCK_MONOTONIC
, and their derivatives should be the acceptable values.
Upvotes: 1