Subj : Re: pthreads and semaphore - Beginer question To : comp.programming.threads From : David Schwartz Date : Fri Aug 05 2005 04:40 pm wrote in message news:1123264045.354491.150550@g44g2000cwa.googlegroups.com... > lampion=(sem_t)1; Is that really legal? There's no 'sem_init' function you're required to call to initialize the semphaore? > pthread_t thread[2]; > int status; > pthread_attr_t attr; > > sem_init(&lampion,NULL,0); > > pthread_attr_init(&attr); > pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE); > pthread_create(&thread[0],&attr,scheduler,NULL);/*sheduler*/ > pthread_create(&thread[1],&attr,worker,NULL);/*worker*/ > pthread_join(thread[0],(void**)&status); > pthread_join(thread[1],(void**)&status); > pthread_exit(NULL); > } Casting the pointer is ugly. Better to use a real 'void *' and pass its address to pthread_join, you can then cast the 'void *'. The problem is that a 'void *' might not be the same size or same format as an 'int'. Casting the address doesn't give the compiler the ability to fix that. DS .