Quote:
Therefore, it is possible that pthread_cond_timedwait would block for ever, which is exactly what one is trying to avoid by using a timed version of 'wait'.
Yes, it is very possible for that to happen.
I am not sure what your understanding of how pthread_cond_timedwait works is. I would point out that once the wait time expires and is turned off, the thread is moved off the sleep queue. Likewise once a sleeping thread is signaled, even by error, it is taken off the sleep queue and the wait timer is turned off. This does not mean that it re-acquires the mutex, etc. If it takes another week before reacquiring the mutex, too bad. If it never gets the mutex back because the other thread has not released it, too bad.
If you have the Lewis & Berg book on Pthreads, this issue is discussed on pages 94 -99. Dave Butenhof also discusses this issue in his book on Pthreads. See section 3.3.2 et al.
BTW, a thought just struck me, are you trying to port a Win32 application which uses eventing to GNU/Linux?