pthread_cond_timedwait vs pthread_mutex_timedlock

Borislav Trifonov
Mon May 4 06:15:00 GMT 2009

It's not clear to me which one I should use.  I have a log-flushing 
thread that I need to wake every X seconds and flush the log (and also 
wake when signaled by a full log buffer or log destructor--by unlocking 
the mutex if I had used a mutex, or signaling the condition if I had 
used that).

What is most important to me is to guarantee that no busy wait will occur.

A possible complication is that I need my code to build on both Linux 
and Windows, so I'm using pthreads for Win32/64 in the latter case.

More information about the Libc-help mailing list