2 little rtems asks, please...

Alex kbyte at iol.pt
Fri Mar 5 09:33:44 UTC 2004

I am begining with the rtems and I have 2 little questions/doubts:

1. Looking to the hello world sample, what is the aim of the final
configuration comments? Is this a remember? Is that importante?

 *  Simple test program -- simplified version of sample test hello.

#include <bsp.h>

#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>

rtems_task Init(rtems_task_argument ignored)
  printf( "\n\n*** HELLO WORLD TEST ***\n" );
  printf( "Hello World\n" );
  printf( "*** END OF HELLO WORLD TEST ***\n" );
  exit( 0 );

/* configuration information */





#include <confdefs.h>*/

/* end of file */

2. Which is the best way to measure the time of an operation?
Suppose you want to measure the execution time of the clock_gettime() function.

I have the following two ways. Does one is better than the other?

REM: I didn't execute my RTEMS programs yet, because I have to
prepare the floppy disk first. But could you give some tips about
the way to measure functions execution time? Is these good ways to do that?

WAY 1:
void diff_timespec(
  struct timespec *start,
  struct timespec *stop,
  struct timespec *result
   int nsecs_per_sec = 1000000000;

   result->tv_sec = stop->tv_sec - start->tv_sec;
   if ( stop->tv_nsec < start->tv_nsec ) {
      result->tv_nsec = nsecs_per_sec - start->tv_nsec + stop->tv_nsec;
   } else
      result->tv_nsec = stop->tv_nsec - start->tv_nsec;

  int status;
  struct timespec start;
  struct timespec current;
  struct timespec difference;
  struct timespec resolution;

  status = clock_gettime( CLOCK_REALTIME, &start );
  assert( !status );

  int nResp = clock_getres(CLOCK_REALTIME, &resolution);

  status = clock_gettime( CLOCK_REALTIME, &current );
  assert( !status );

  diff_timespec( &start, &current, &difference );

WAY 2:

 status = clock_gettime( CLOCK_REALTIME, &start );

REM: It is very important for me that the technique be POSIX compliant.

Any advices?

Thanks a lot.

IOL Flash. A net normal em versao acelerada.
Precisa de uma caixa de correio maior? Com o IOL Flash pode ter uma caixa com 21MB de espaco.
Saiba mais sobre o IOL Flash: http://www.iol.pt/central_utilizador/iol_flash/

More information about the users mailing list