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


Kaz Kylheku wrote:
> 
> 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.

And the high-res-timers patch is an attempt to do so.  At
this time I am adding support for clock changes to this
patch.  It is hoped that the patch will be accepted in the
2.5 kernel.

It should be noted, however, that clock changes that are
made by ntp code are a bit of a tough nut to crack.  The
best solution would be to change the rate of the system
"jiffie" clock rather than "slipping" the wall clock WRT the
"jiffie" clock as is done now.  Unfortunately this requires
work for each platform...

-- 
George Anzinger   george@mvista.com
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml


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