Subj : Re: pthreads and semaphore - Beginer question To : comp.programming.threads From : David Schwartz Date : Fri Aug 05 2005 05:38 pm wrote in message news:1123284806.836562.142730@g44g2000cwa.googlegroups.com... > Hi, > I did call sem_init: > sem_init(&lampion,NULL,0); Right, but you corrupted it *after* that. >> 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. > Yes, but I used this in other multithreaded programs, and never gave > any problem. I found it in pthread-primers (a book). > Do you allso happen to know what might be wrong with my semaphore? Or, > how I should do what I described, without a semaphore (although I > prefer to use a semaphore, since it's made for such a kind of > things...)? You muck up the sempahore by modifying its value. You are only supposed to use the sem_* functions on the sempahore. DS .