This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Calling cyg_thread_create() from static constructors


uwe.kindler@cetoni.de writes:

> Hello,
> 
> is it allowed in eCos to call cyg_thread_create() and
> cyg_thread_resume() from static constructors?
> 
> I have the following problem. My C++ application contains a static
> object. This object creates a thread with cyg_thread_create() and
> then calls cyg_thread_resume() in its constructor.
> 
> I single stepped the function cyg_hal_invoke_constructors(). As soon
> as this object is created (it is the last one that is constructed
> cyg_hal_invoke_constructors()) it is not possible to view the list
> of threads from insight or GDB any longer. If I select View, Thread
> List in insight, I get an empty thread list or an error message that
> it was not possible to get thread list. If I remove this object from
> my application, then this problem does not occur.
> 
> Is there any solution for this problem or should I simply not call
> these two function from a static constructor?.

cyg_thread_create() and cyg_thread_resume() are designed to allow you
to create and start threads at any time before the scheduler starts,
including during static constructors. So long as they are not
prioritized to happen before the scheduler and thread constructors run
it should all work. Various eCos packages create worker threads in
exactly this way.

I have just checked this out with a PC and the HTTPD server, which
creates a thread in a constructor, and I don't see any problems
listing the threads from GDB. This may be a problem with the way
Insight handles it's thread list. It is certainly not an eCos problem.

Alternatively, there may be something wrong with the way you are
creating the thread. Or maybe you are corrupting the thread list in
some other piece of code. Does the application work correctly other
than this failure to view the thread list?

-- 
Nick Garnett                                          eCos Kernel Architect
http://www.ecoscentric.com                     The eCos and RedBoot experts
Besuchen Sie uns vom 14.-16.02.06 auf der Embedded World 2006, Stand 11-222
Visit us at Embedded World 2006, NÃrnberg, Germany, 14-16 Feb, Stand 11-222


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]