/* snap the time */
cycle1=ClockCycles( );
/* do something */
sleep(1);
/* snap the time again */
cycle2=ClockCycles( );
ncycles=cycle2-cycle1;
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 );
sec=(float)ncycles/cps;
printf("The cycles in seconds is %f \n",sec);
return EXIT_SUCCESS;
}
What’s the reason for this results not expected???
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)
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