This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
pthread_cond_timedwait vs pthread_mutex_timedlock
- From: Borislav Trifonov <trifonov at cs dot ubc dot ca>
- To: libc-help at sourceware dot org
- Date: Sun, 03 May 2009 23:15:17 -0700
- Subject: pthread_cond_timedwait vs pthread_mutex_timedlock
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.