Quote:
Originally Posted by wjevans_7d1@yahoo.co
Can you tolerate a relatively high overhead on the very first call, or perhaps a "before-the-first" call that sets everything up?]
|
Thanks for the answer.
Yes - I can publish the parameters of the converstion function that
calculates the actual time based on rdtsc in shared memory so that this
information must be obtained only once.
I will go along these lines for my code to run on x86 Linux - for now.
Such a calculation scheme has some disadvantages though (I repeat information
I found on wikipedia):
- x86 specific
- Not all INTEL compatible CPUs might properly support it
- Potential problems on multi-CPU systems when CPU affinity is not
guaranteed (timer value may not be guaranteed to be in sync on all
virtual or real CPUs)
- Potential problems with variable clock rate and hibernation facilities
Wikipedia cites a Microsoft site that states that these issues are the reason
why the QueryPerformanceCounter API exists in Win32. Theoretically such
an API could (should ?) be provided on Linux. It would cancel out the effects
caused by the problems mentioned above and provide a reliable high resolution
timer.
But QueryPerformanceCounter as well as a corresponding hypothetical Linux
counterpart would still not provide what I am looking for: a moderate
resolution time that is accessible in user space.
With the mindset of wishing Linux to be superior or at least equal in all
even-so-small details I wonder whether it would make sense to suggest two
enhancements to the Linux kernel:
1. Provide a function that picks up the current time in user space with a
resolution of somewhere in the 50 millisecond range. No kernel transistion
should be necessary in order to achieve a performance somewhere in the
low hundreds of nanoseconds.
2. Provide an API call that provides a "dirt-effect-corrected" high resolution
counter. A kernel transition is probably unavoidable so that this
API cannot be used excessively.
Has anybody suggested such things? How could I "file" such a suggestion?