Subj : Re: breakdown To : comp.programming.threads From : Eric Sosman Date : Fri Feb 11 2005 11:38 am fabrizio wrote: > Hello, > > first thread executes : > ---- > pthread_mutex_lock(&(pFilter->condmut)); > while(pFilter->received_packet != TS_PER_UDP) { > pthread_cond_wait(&(pFilter->condvar),&(pFilter->condmut)); > } > memcpy(buffer,pFilter->InBuffer,buffer_size); > pFilter->next_packet = pFilter->InBuffer; > pFilter->received_packet = 0; > pthread_mutex_unlock(&(pFilter->condmut)); > ---- > > second thread executes : > ---- > pthread_mutex_lock(&condmut); > memcpy(next_packet,packet,TSPACKET_SIZE); > received_packet++; > next_packet += TSPACKET_SIZE; > if (received_packet == TS_PER_UDP) { > pthread_cond_signal(&condvar); > } > pthread_mutex_unlock(&condmut); > ---- > > > executing this leads to total freeze on my machine. > I have to reset it and some files get corrupted. > Can you see anything wrong in this code ? Try changing `!= TS_PER_UDP' to `< TS_PER_UDP' in the first thread. (A hunch, not a diagnosis. The treatement of `received_packet' looks peculiar in any case, and may need to be re-thought.) -- Eric.Sosman@sun.com .