1
下面在pthread_create ENOSYS誤差是簡單的代碼我用VxWorks中的RTP項目用於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線程組件添加到內核的詳細步驟