首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CLOCK_TAI的pthread条件支持

CLOCK_TAI的pthread条件支持
EN

Stack Overflow用户
提问于 2016-03-25 06:55:22
回答 1查看 86关注 0票数 1

我一定是漏掉了什么。我可以使用clock_gettime获取CLOCK_TAI。

代码语言:javascript
复制
#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 );
}

当按如下方式编译时,它会产生以下输出:

代码语言:javascript
复制
g++ -o taiTest taiTest.cxx -lpthread -lrt    
./taitest$ ./taiTest 
    22 11

其中EINVAL = 22,CLOCK_TAI = 11。

这里的任何想法或帮助都非常感谢。提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2016-03-26 02:45:36

根据手册页面,pthread_condattr_setclock()仅接受一组有限的时钟标识值。CLOCK_TAI不是其中之一。手册页面谈到了系统时钟,这听起来有点模棱两可。CLOCK_REALTIMECLOCK_MONOTONIC及其衍生物应为可接受的值。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36211357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档