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;
}
Previously, J. Scott Franko wrote in qdn.public.qnxrtp.os:
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;
}
\
You are right and as far as I remember it’s the same in Neutrino courses.
Alain.
Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:
Previously, J. Scott Franko wrote in qdn.public.qnxrtp.os:
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;
}
You are right and as far as I remember it’s the same in Neutrino courses.
Alain.
The course material doesn’t do the division. The %d’s in place of
%lld’s were probably what you remembered. Long since fixed.
Steve
Previously, Steven Dufresne wrote in qdn.public.qnxrtp.os:
Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
Previously, J. Scott Franko wrote in qdn.public.qnxrtp.os:
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;
}
You are right and as far as I remember it’s the same in Neutrino courses.
Alain.
The course material doesn’t do the division. The %d’s in place of
%lld’s were probably what you remembered. Long since fixed.
Steve
Exactly Steven.
Alain.
J. Scott Franko <jsfranko@switch.com> wrote:
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.
Other methods of finding functions:
If you know what function or macro you’re looking for –
functions and macros are listed in alphabetical order
(see About this Reference for appropriate links);
there’s also the Library Summary section that categorizes the functions.
I’ll fix the example. Thanks.
-Donna
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;
}