I am working with MaRTE OS (a Hard RTOS with a Minimal RT POSIX.13 subset [marte webpage] ) and at a low level programing.
I use IA32_CLOCK_MODULATION MSR to change the CPU frecuency. It allows to me to modulate the dutycycle of the on-demand clock. The dutycycle field encoding is 3 bits. Then, I have a set of fixed dutycycle values.
There is a table whit the theoretical values in the specification vol 3A Chap 13 page 13-16 . And two ways to get the real working-frequency. A) get the time that a well-defined loop take to complete at different frequencies, and B) use IA32_MPERF MSR and IA32_APERF MSR (Chap 13, page 13-2) which division is the ratio of the processor frequency.
But I find significant differencies between both methods and the theoretical values (show in table below). I trust more in tsc than in aperf/mperf ratio. But I would like to use last method because it involve less time to know the ratio.
On the other hand, I do not sure that the ratio provided by APERF/MPERF division is really of the frequency. And I need to know the frequency as accuracy as possible due to real time purposes.
How should I get the working-frequency??? Are there other methods?
I am a little cofused.
theoretical - APERF/MPERF - TSC
1.000 - 1.000 - 1.000
0.875 - 0.877 - 0.853
0.750 - 0.760 - 0.708
0.625 - 0.638 - 0.568
0.500 - 0.538 - 0.448
0.375 - 0.434 - 0.325
0.250 - 0.363 - 0.239
0.125 - 0.270 - 0.132