[PATCH] clock_nanosleep(2), pthread_condattr_[gs]etclock(3)

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Wed Jul 20 22:04:00 GMT 2011

On Wed, 2011-07-20 at 16:11 +0200, Corinna Vinschen wrote:
> On Jul 20 04:50, Yaakov (Cygwin/X) wrote:
> > Actually, no need to panic, I took a closer look at this, and it's not
> > all that hard at all, so I'll go ahead and implement
> > pthread_condattr_[gs]etclock() as well.  Just give me a day or two to
> > get it done.  In the meantime, I'll proceed with the revised newlib
> > patch.
> Thanks.

Not taking the following issue into account, my patches to implement
pthread_condwait_[gs]etclock() and update sysconf() are attached.  (The
chunk for include/cygwin/version.h is not included, as that will depend
on which order these patches are applied.)

> The only problem I see is the fact that a call to clock_settime
> influences calls to clock_nanosleep with absolute timeouts(*).
> The problem is that we convert absolute timeouts to relative timeouts
> and then use the timeout facility of the WFMO function to handle the
> timeout for us.  IMO this is neither very reliable, nor is it elegant.
> So, here's the question.  Shouldn't we better use waitable timers
> to implement this sort of stuff?  Waitable timers are pretty easy to
> use, they support relative and absolute timeouts with an accuracy of 100
> ns in the API and a real accuracy which only depends on the underlying
> HW, and they are especially not subject to the 49.7 days overflow
> problem.

I see your point.  The question is how to use waitable timers for

> (*) Does it also influence pthread_cond_timedwait?  This information seems
>     to be missing in SUSv4.

The last paragraph of RATIONALE -> Timed Wait Semantics states:

> For cases when the system clock is advanced discontinuously by an
> operator, it is expected that implementations process any timed wait
> expiring at an intervening time as if that time had actually occurred.

Of course, this would be an old problem with pthread_cond_timedwait().


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygwin-posix-clock-selection.patch
Type: text/x-patch
Size: 896 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20110720/0585684a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygwin-pthread_condattr_getclock.patch
Type: text/x-patch
Size: 7702 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20110720/0585684a/attachment-0001.bin>

More information about the Cygwin-patches mailing list