ClockCycles() kernel calls different values?

Hi Community

I’am try to understand the ClockCycles() kernel calls and get some different
non expected results.
I’am using a i386 CPU 1.5 GHz mobile

result—> 1506694794 cycles elapsed --------> this is OK

result—> This system has 319518504 cycles/sec. -->NOK expected ~ 1506694794 !!!

result–> The cycles in seconds is 4.715517 → NOK expected ~1 sec !!!

#include <sys/neutrino.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/syspage.h>

int main( void )
uint64_t cps, cycle1, cycle2, ncycles;
float sec;

/* snap the time */
cycle1=ClockCycles( );

/* do something */


/* snap the time again */
cycle2=ClockCycles( );
printf("%lld cycles elapsed \n", ncycles);

/* find out how many cycles per second */
cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
printf( "This system has %lld cycles/sec.\n",cps );
printf("The cycles in seconds is %f \n",sec);



What’s the reason for this results not expected???

Thank you !!!

Something doesn’t add up, I have never heard of a 386 running at 1.5Gig. I’m guessing it’s at least a pentium class processor.

It’s quite possible that on your hardware QNX isn’t able to properly calculate the cycles per seconds (which should be the same as the processor clock). Mobile CPU and hardware often play with CPU clock to save power. I’d bet that when QNX computed clock cycle the clock was somehow running at lower frequence (~300Mhz)

Thank You for your answer yes this is possible!

So my Programm is ok.

I use a Intel BX80536NC1500EJ Intel Celeron M 370 1.50GHz UFCPGA (BX80536NC1500EJ


Yes your program looks ok.

Interestingly enough, I heard Intel made a change to their P4 line. These processor can also change their cpu clock dynamicly, the change consist of make the CPU clock counter immune to processor throttleing and also count at the rate CPU clock. Not sure if that applies to other CPU then P4 core.

it could be the case where your program is being suspended by a higher priority process. Why don’t you run your app with “time” command and see what number it gives you.
ie. # time test_time
where test_time is your program

Notice how the number of cycles is the same as the CPU frequency, one would be very lucky to have the two numbers match ;-)