This is the mail archive of the
pthreads-win32@sources.redhat.com
mailing list for the pthreas-win32 project.
Problem with pthread_cond_timedwait().
- From: "Nir Nizry" <nir dot nizry at bluesoft-inc dot com>
- To: <pthreads-win32 at sources dot redhat dot com>
- Date: Tue, 23 Jul 2002 07:20:01 +0200
- Subject: 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
-----------------------------------------