The following example code in
QNX Neutrino OS
Version 2.1 (…
library reference
s
SYSPAGE_ENTRY()
has a slight bug. See comment in the middle of the code below. Also,
this document page was not found with search on SYSPAGE_ENTRY(), I had
to uncheck whole word and search on all text instead of topic text.
Sometimes this produces way to many entries to be practicle, so I often
hesitate to use it.
The example:
#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;
float sec, ncycles;
// snap the time
cycle1=ClockCycles( );
// do something
printf(“poo\n”);
// snap the time again
cycle2=ClockCycles( );
ncycles=cycle2-cycle1;
printf("%d cycles elapsed \n", ncycles);
The Bug:
The printf line above produces zero. You either need %f ( but it looks
crappy as a float print), or you need to leave it a %d and typecast
ncycles to be a uint64_t.
// find out how many cycles per second
cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
printf( “This system has %lld cycles/sec.\n”,cps );
sec=ncycles/cps;
printf(“The cycles in seconds is %f \n”,sec);
return EXIT_SUCCESS;
}