【发布时间】:2016-07-12 16:52:09
【问题描述】:
我必须遗漏一些东西。我可以使用clock_gettime 获得CLOCK_TAI。但是,当我尝试将 CLOCK_TAI 与 pthread 条件一起使用时,我得到一个 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 );
}
当按如下方式编译时,它会产生以下输出:
g++ -o taiTest taiTest.cxx -lpthread -lrt
./taitest$ ./taiTest
22 11
其中 EINVAL = 22 且 CLOCK_TAI = 11。
这发生在我的 Ubuntu 14.04 系统和使用 Yocto 构建的操作系统的嵌入式 ARM 设备上。
非常感谢这里的任何想法或帮助。提前致谢。
【问题讨论】:
标签: c time linux-kernel pthreads posix