This is the mail archive of the cygwin mailing list for the Cygwin 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: clock_getres(CLOCK_REALTIME, .) may return an outdated and too high resolution

Corinna Vinschen wrote:
On Mar 27 20:59, Christian Franke wrote:
Corinna Vinschen wrote:
On Mar 27 20:01, Christian Franke wrote:
Corinna Vinschen wrote:
On Mar 26 19:00, Christian Franke wrote:
Corinna Vinschen wrote:
I see your point, but what bugs me a bit is the fact that
clock_getres(CLOCK_REALTIME) and clock_setres(CLOCK_REALTIME) will
always return the same value coarsest, regardless what value has been set.
If clock_setres was called and succeeded, then clock_getres(.)
should return the value set before.

If clock_setres was not called, the coarsest value is IMO the only
value that can be guaranteed.

The actual value returned by NtQueryTimerResolution is simply
useless in this context: It is the minimum of all resolutions
currently set by all running processes. It may change at any time.
There is apparently no way the query the current setting of the
current process.
Uh, right, I misunderstood. I reverted the change to clock_setres.
Sorry, I probably forgot to mention that NtSetTimerResolution
returns the same useless actual value than NtQueryTimerResolution.

I would suggest:

     status = NtSetTimerResolution (period, TRUE,&actual);
     if (!NT_SUCCESS (status))
       { ... return -1; }
  -  minperiod = actual;
  +  minperiod = period;
But that's not right.  The "actual" value is not useless, but the value
the resolution has actually been set to.
No, again this is the minimum of all resolutions currently set by
all processes.

   The OS just doesn't support
arbitrary values for the period.

Yes - but in 'actual' a smaller value than the value set for the
current process may be returned.
Hmpf, ok. Boy is that ugly.

Yes, aka broken by design :-)

There should be a function to query the actual setting for the current process only. But there is none.

   Is there a chance that actual is bigger
than period?  In that case we should perhaps set minperiod like this:

minperiod = MAX (actual, period);

According to some experiments this can only happen if period < finest. In this case NtSetTimerResolution also succeeds and returns actual == finest.


-- Problem reports: FAQ: Documentation: Unsubscribe info:

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