RTEMS Logo

RTEMS 4.6.1 On-Line Library


Initialization Code main() - C Main

PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

7.3.4: main() - C Main

This routine is the C main entry point. This is a special routine and the GNU Compiler Suite treats it as such. The GNU C Compiler recognizes main() and automatically inserts a call to the compiler run-time support routine __main() as the first code executed in main().

The routine __main() initializes the compiler's basic run-time support library and, most importantly, invokes the C++ global constructors.

The precise placement of when main() is invoked in the RTEMS initialization sequence insures that C Library and non-blocking calls can be made in global C++ constructors.

The shared implementation of this routine is located in the following file:

c/src/lib/libbsp/shared/main.c

In addition to the implicit invocation of __main, this routine performs some explicit initialization. This routine sets the variable rtems_progname and initiates multitasking via a call to the RTEMS directive rtems_initialize_executive_late. It is important to note that the executive does not return to this routine until the RTEMS directive rtems_shutdown_executive is invoked.

The RTEMS initialization procedure is described in the Initialization Manager chapter of the RTEMS Application C User's Guide. Please refer to that manual for more information.


PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

Copyright © 1988-2004 OAR Corporation