Vxworks RTP项目中pthread_create的ENOSYS错误

时间:2012-12-24 15:07:00

标签: c vxworks

下面是我用来测试Vxworks RTP项目中的线程功能的简单代码

#define NUM_THREADS 2 

void *PrintHello(void *threadid) 
{ 
    long tid = 0;   
    tid = (long)threadid;
    printf("Hello World! It's me, thread #%ld!\n", tid);
    pthread_exit(NULL); 
    return NULL;
} 

int main ()
{ 
  int rc;   
  long t;   
  pthread_t threads[NUM_THREADS];   
  pthread_attr_t attr;

  pthread_attr_init(&attr);

  for(t=0; t<NUM_THREADS; t++)  
  {     
    printf("In main: creating thread is : %ld\n", t);   
    rc = pthread_create(&threads[t], &attr, PrintHello, (void *)t); 
    if (rc) printf("ERROR; return code from pthread_create() is : %d\n", rc);   
    //pthread_join(threads[t],NULL);    
  } 
  pthread_exit(NULL);   
  return 0;
}

输出:

In main: creating thread is : 0 ERROR; return code from pthread_create() is : 71 
In main: creating thread is : 1 ERROR; return code from pthread_create() is : 71

错误'71'点对应'ENOSYS'错误代码,并且基于搜索发现Vxworks内核中未启用POSIX线程组件。

vxWorks pthreads帖子也与此相关。但我不确定我需要在哪个文件中启用'INCLUDE_POSIX_PTHREAD_SCHEDULER'组件(configRtp.mk/*.cdf文件)。 请提供有关如何将POSIX线程组件添加到内核

的详细步骤

1 个答案:

答案 0 :(得分:1)

通过修改内核配置将组件添加到内核。最简单的方法是在workbench中打开VxWorks Image Project,然后双击“Kernel Configuration”。这应该启动Componenent Configuration Editor,如下所示。

您可以使用“查找”(至少在Windows上按Ctrl-F)按组件名称进行搜索。

Component Configuration