I have 3 processes which need to be synchronized. Process one does something then wakes process two and sleeps, which does something then wakes process three and sleeps, which d
The problem seems to come from passing an invalid timeout argument.
At least on my machine, the first failure is not ETIMEDOUT but:
!!!!!! sem2 sem_timedwait failed: Invalid argument, val now 0
Now, if I write:
if (ts.tv_nsec >= 1000000)
(note the addition of =) then it works fine. It's another question why the state of semaphore gets (presumably) effed up so that it times out on subsequent attempts or simply blocks forever on straight sem_wait. Looks like a bug in libc or the kernel.