[ECOS] Is main a thread

Nick Garnett nickg@ecoscentric.com
Wed Nov 5 13:04:00 GMT 2008

Andrew Lunn <andrew@lunn.ch> writes:

> On Wed, Nov 05, 2008 at 09:45:27AM +0100, Robert Brusa wrote:
> > Hi
> > the function main has a somewhat special role, but little can be found  
> > about it in eCOSs documentation. I found the statement, that some  
> > libraries are initialized when main is called. Further: I have written  
> > small test-apps for my modules and normally these apps do not include a  
> > main, but only one (or several) threads. Then I built an app that 
> > included a main only, but no threads. Both approaches work, but can I do 
> > everything that is allowed in threads also in main? Or in other words:
> >
> > 1) Is main just a thread or is it kind of the idle task of eCOS?
> main is a full eCos thread. It is not however a full POSIX thread, as
> far as i remember. 

It depends. If the LIBC startup package is included then main() will
be called and will be run on an eCos thread. If the POSIX package is
also present then main() will be run on a POSIX thread. If neither
package is present then main() will not be called at all, and the
application must start from cyg_start() or cyg_user_start().

It is also possible to configure the LIBC startup package to call
main() from cyg_user_start() in non-kernel configurations.

Nick Garnett                                      eCos Kernel Architect
eCosCentric Limited    http://www.eCosCentric.com      The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.     Tel: +44 1223 245571
Registered in England and Wales:                        Reg No: 4422071

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list