pthread_cond_timedwait/posix timers
Kaz Kylheku
kaz@ashi.footprints.net
Thu Aug 8 08:54:00 GMT 2002
On Wed, 7 Aug 2002, Amos Waterland wrote:
> 1.1 There is a race condition in __pthread_timedsuspend_new(), where if the
> thread is preempted between its __gettimeofday() and __libc_nanosleep()
> calls, pthread_cond_timedwait() will return after the desired time.
It's not possible for a function to not return after the desired time,
since it has to execute instructions after it is woken up. It may be
preempted at any time before it returns.
We use nanosleep() with a relative timeout because the kernel doesn't
give us a clock_nanosleep() that could be made to sleep absolutely.
This is rather ironic, because sleeps in the kernel are based on
absolute timeouts! So the relative timeout in nanosleep() has to be
converted back to an absolute jiffy count.
Fixing these kinds of issues requires kernel support.
--
Meta-CVS: solid version control tool with directory structure versioning.
http://users.footprints.net/~kaz/mcvs.html http://freshmeat.net/projects/mcvs
More information about the Libc-alpha
mailing list