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] |
On Mar 26 19:00, Christian Franke wrote:Corinna Vinschen wrote:Uh, right, I misunderstood. I reverted the change to clock_setres.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.
status = NtSetTimerResolution (period, TRUE, &actual); if (!NT_SUCCESS (status)) { ... return -1; } - minperiod = actual; + minperiod = period;
- Unlike on e.g. Linux, CLOCK_REALTIME does not provide a better resolution than gettimeofday().We can only use what the OS provides. Starting with Windows 8 there will be a new function call GetSystemTimePreciseAsFileTime: http://msdn.microsoft.com/en-us/library/windows/desktop/hh706895%28v=vs.85%29.aspxThis would provide an easy solution for>= Win8: clock_gettime returns GetSystemTimePreciseAsFileTime, clock_getres returns constant 1us.As far as I can tell from a quick debug session, the implementation of the underlying RtlGetSystemTimePrecise function is based on a spiffy combination of the standard clock tick with the performance counter. I'm not very good at assembler debugging, but the essence is access to some known and some unknown time values from SharedUserData, a call to RtlQueryPerformanceCounter, and a bit of arithmetic.
Maybe we can implement something similar without waiting for W8? Does anybody have code to combine a not so precise clock with a more precise counter to create a more precise clock?
-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |