This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: pthread_cond_timedwait/posix timers
- From: Kaz Kylheku <kaz at ashi dot footprints dot net>
- To: Amos Waterland <apw at us dot ibm dot com>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Thu, 8 Aug 2002 08:54:29 -0700 (PDT)
- Subject: Re: pthread_cond_timedwait/posix timers
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