
Niall Douglas wrote:
The standard says nothing about what is or is not a spurious wakeup unfortunately.
What does it matter? We all know what is or is not a spurious wakeup - a return from the wait without the condition being notified.
My reading of http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_cond_timedw... says that the timed wait may not return timed out if abstime has not passed.
Correct, if it returns before abstime has passed, it returns 0, not ETIMEDOUT.
Unfortunately abstime is measured against the system clock which may arbitrarily move around, but that's the POSIX definition.
abstime is measured against the condition variable's clock, which is the system clock by default, but can be changed. But this is irrelevant.
For example, would the community be happy if on Windows timed waits always were at least the timeout interval requested?
Code that works in the presence of spurious wakeups will retry the wait on its own. So the only people who would be helped would be those whose code doesn't expect spurious wakeups. We've been here before. Such code is simply incorrect. We know that "the community" would prefer for spurious wakeups to not exist, and in fact often pretends that they do not. But that's just wrong.