This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]