Re: High Resolution timers support in Fedora?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ernest L. Williams Jr. wrote:
> I would like to play with high resolution timers under linux and GCC.
> 
> Where is the function "gethrtime()" ?  

gethrtime on Solaris is using the cycle counters.  This is an unreliable
clock, at least on x86/x86-64 since the clock speed can vary and, more
importantly, the cycle counter value could vary between different
processors on the system.  Although the latter works correctly on most
small SMP machines it is not guaranteed.

Having said that, the C library provides the POSIX interfaces
clock_gettime and friends.  Before the kernel support was added to
support them, the clock_gettime interface for the CPU clocks was using
the rdtsc instruction on x86 and x86-64.  So the interfaces were really
equivalent to the gethrtime interface on Solaris.  With kernel support
available now these calls are syscalls but they still provide a high
resolution (still based on rdtsc data, but more reliable).  The big
difference is that now the CPU clock really only counts the time the
thread/process uses the CPU.  If you just need an incremental time, then
use CLOCK_REALTIME instead.  Its exported resolution isn't quite as high
but it runs continuously.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
fedora-test-list mailing list
fedora-test-list@xxxxxxxxxx
To unsubscribe: 
https://www.redhat.com/mailman/listinfo/fedora-test-list

[Index of Archives]     [Fedora Desktop]     [Fedora SELinux]     [Photo Sharing]     [Yosemite Forum]     [KDE Users]