[PATCH] clock_nanosleep(2)

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Aug 2 15:43:00 GMT 2011

On Aug  1 23:09, Yaakov (Cygwin/X) wrote:
> On Sun, 2011-07-31 at 10:24 +0200, Corinna Vinschen wrote:
> > anything new from the clock_nanosleep frontier?
> Sorry, I've been having elusive problems with CVS HEAD that have been
> making it hard to test my patch.
> Here's what I have so far, FWIW.  So far I've found two problems with
> it: the remaining time returned is incorrect, based on testing of
> nanosleep(),

Does that mean the return value from NtQueryTimer is unreliable?  In
what way is it wrong?  Does nanosleep wait too long or not long enough?
If NtQueryTimer is unusable, maybe we should just skip the idea to return
the remaining time from cancelabel_wait and simply use the return
value from hires_ms::timeGetTime_ns() to return the remaining time
from {clock_}nanosleep, kind of like

  LONGLONG remaining = hires_ms::timeGetTime_ns ();
  LONGLONG remaining = hires_ms::timeGetTime_ns () - start;
  rem->tv_sec = remaining / NSPERSEC;
  rem->tv_nsec = remaining - (rem->tv_sec * NSPERSEC);

> and the pthread_spin chunk doesn't look right (previously
> the timeout would repeat in the while loop, but that won't happen the
> way the waitable timer is set up).

It doesn't look wrong to me, but then again, I didn't test it...
> I'll try to get back to this as soon as I am able to test this properly.
> In the meantime, is there anything obvious I'm missing?

Nothing I can think of.  This looks good.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

More information about the Cygwin-patches mailing list