C or assembly code to find current cpu core speed
- by honestann
How can my application efficiently determine the following information peroidically while it executes:
1: current speed of each of the 8 CPU cores.
2: which core the code is currently executing on.
My application is C and assembly-language, so any solution in either C or assembly-language is fine. This code needs to execute quickly, so creating, reading and processing a file generated by "cat /proc/cpuinfo" is much too slow.
The cores slow-down and speed-up automatically, probably to keep CPU temperature under control. Therefore, a one-time measure is not sufficient for my purposes.
My application already reads and subtracts the cpu cycle counter in assembly language to determine number of clock cycles, but my program cannot compute elapsed time in nanoseconds unless it knows the current clock frequency of the cpu cores (and which core the code is executing on). Thanks!