Does anyone use the main() function in rtems programs?

Joe OS joe_os2001 at yahoo.com
Thu Jul 1 15:33:59 UTC 2004



Hi,
I am sorry about this beginner question, but I cant
solute this problem:

I am a beginner concerning rtems. I already made some
simple programs and they workek.
In these programs I used configuration information
like

#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
#define CONFIGURE_TICKS_PER_TIMESLICE   1
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_MICROSECONDS_INIT
#define CONFIGURE_INIT
#include <confdefs.h>

So everything worked fine.

Now, I want to write rtems programs with the
portability in mind,
like, use the main() function and posic api. So I
wrote one simple
program using the main() instruction, instead of the
rtems macro
 representing the main. I

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

int main()
{
  puts( "\n\n*** POSIX PROGRAM ***" );
  return 0;
}

I used the make file of the rtmes program version to
build this c posix
like program and everuthing worked fine. Remember that
I didn’t define
any symbols and didn’t include the confdefs.h either!!
But it worked!


Now I want to launch one extra thread and the problem
arises:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>

void task2()
{
   int counter=0;
   int i;

   for(i=0;i<100000;i++)
   {
    counter++;
    if((counter % 10000) == 0)
 {
  puts( " P " );
 }
   }
}

int main()
{
  pthread_t count;
  int taskparameter = 0;

  puts( "\n\n*** POSIX PROGRAM ***" );

  //Start task 2
  int task_ret;
  task_ret = pthread_create(&count, NULL, (void *)
task2, (void *) &taskparameter);
  if (task_ret)
  {
    perror("error creating task2");
    return 0;
  }
  pthread_join(count,NULL);
  return 0;
}

Every time the program is executed, the
pthread_create() function
always fails! Once more again, I didn’t define any
symbols nor confdefs.h, because if I define for
example

#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
#define CONFIGURE_TICKS_PER_TIMESLICE   1
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_MICROSECONDS_INIT
#define CONFIGURE_INIT
#include <confdefs.h>

many errors appear during execution of the original
make file…

My question is:
When using the c posix fashion, using the pure main()
function,
is it needed to define the symbols and use confdefs,
or there is
 other way to compile a program…

I searched in the rtems samples and didn’t find any
programs using
the main() function, so any c posix fashion sample
program and make
file would be appreciated…

Any comments?

Thanks to everybody,

Joe


		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 



More information about the users mailing list