On Jul 21 16:02, David Allsopp wrote: > Corinna Vinschen wrote: > > Sent: 21 July 2021 10:33 > > To: cygwin-patches@cygwin.com > > Subject: Re: Fix nanosleep returning negative rem > > > > On Jul 21 11:30, Corinna Vinschen wrote: > > > I wrote a quick STC using the NT API calls and I can't reproduce the > > > problem with this code either. The output is either > > > > > > SignalState: 1 TimeRemaining: -5354077459183 > > > > > > or > > > > > > SignalState: 0 TimeRemaining: 653 > > > > > > I never get a small negative value in the latter case. Can you > > > reproduce your problem with this testcase or tweak it to reproduce it? > > > > Now I actually attached the code :} > > :) Yes, I can reproduce - I didn't even need a loop! Third time: > > dra@Thor /cygdrive/c/Scratch/nanosleep > $ ./timer > SignalState: 0 TimeRemaining: -1151 > > That said, I can get it easily get this on my desktop (AMD Ryzen > Threadripper 3990X) but not at all on my laptop (Intel Core i7-8650U). > On the laptop, ignoring the couple of signalled cases, 747 runs of > timer.c give values between 131597-149947 with a very narrow SD > (~4000) whereas on the AMD chip, 738 runs gives a range of -2722 to > 149896 with a relatively wider SD of ~23000. > > The CI system where this was first seen is an virtualised Intel system > so it doesn't appear to be as simple as CPU manufacturer or even core > count.
Weird. I pushed your patch. > That said, I'm not at all familiar with the details of how this > works, but I expect the timer for these things is part of the chipset, > not the CPU?! As timers go, the timer behind the NtCreateTimer scenes is a simple interrupt based timer with a default resolution of 15 ms. Thanks, Corinna