clock_gettime, get_clockfreq

edA-qa mort-ora-y eda-qa@disemia.com
Mon Apr 30 07:02:00 GMT 2012


I'm trying to understand how clock_gettime works and I'm uncertain as to
how scaled CPU frequencies are handled.

If I look at the clock_gettime code it calls a function call
get_clockfreq.  This patterns is the same in multiple versions of this code.

On linux this frequency is read once from the '/proc/cpuinfo' file. This
information I believe is set only once at system startup. However,
during operations the actual frequency will change. I can indeed get it
to have any number of values in the cpuinfo file. How does clock_gettime
actually resolve this issue? Does the TSC somehow automatically
represent clock-cycles in this listed frequency?

Also, I noticed a 4096 buffer in get_clockfreq which reads the timer.
There is a counter which says proc won't produce larger files, yet I
have system where the 'cpuinfo' file is clearly larger than this. I'm
sure the first 4K will have a speed in it, but the speed does not need
to be the same across all CPUs.

Note: I'm looking at the x86_64 code for Linux.

-- 
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/libc-help/attachments/20120430/3353ccbb/attachment.sig>


More information about the Libc-help mailing list