// tested pthread once,create,join #include #include #define THREADS 20 extern "C"{ #include #include #include int once_counter=0; pthread_once_t once_control = PTHREAD_ONCE_INIT; void once_fn(void) { puts("in once_fn"); once_counter++; } void *threadfunc(void *parm) { int status; int threadnum; int *tnum; tnum = (int *)parm; threadnum = *tnum; //printf("Thread %d executing\n", threadnum); status = pthread_once(&once_control, once_fn); if ( status < 0) printf("pthread_once failed, thread %d, errno=%d\n", threadnum, errno); //pthread_exit((void *)0); return NULL; } void once_rtn(){ printf("in once init\n"); } void test(){ processor p[10]; int status; int i; int threadparm[THREADS]; pthread_t threadid[THREADS]; void* thread_stat[THREADS]; for (i=0; i