This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with pthread_cond_timedwait().


Hello All,

I have a problem with pthread_cond_timedwait().
I have a system with 5 threads that in their main loop wait with a timeout
(timedwait) on a condition variable to be set.
what I get is, that sometimes a thread enters the pthread_cond_timedwait()
function, and doesn't come out, even if the timeout time arrives. after this
happens, the other threads get stuck in the mutex lock before entering the
pthread_cond_timedwait() as if the mutex is already locked.

I suspect that somehow either the pthread_cond_timedwait() function does not
release the mutex or does not return when the timeout occurs.

does someone have an idea' or know of such an incident (or maybe a bug in
pthread)??

Thanks.

Nir.

I added the code fraction where it get stucked (this is the ONLY place in
the code where the messageMutex is locked):


pthread_mutex_lock(messageMutex);

waitResult = 0;
while( m_theGeneralQueue->isEmpty() && !shouldStopThreadGlobalLoop &&
(waitResult != ETIMEDOUT))
	waitResult = pthread_cond_timedwait(newMessageEvent, messageMutex,
&timeout);

pthread_mutex_unlock(messageMutex);


-----------------------------------------

mailto:nir.nizry@bluesoft-inc.com

-----------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]