pthread_cond_timedwait is a nice little function that can be used to "atomically" release a mutex, wait for a condition with a timeout and then acquire the mutex. The first pitfall of this method is that the "timeout" is an absolute time, not a relative
Read More...