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: How to know if the scheduler is already running


Stanislav Meduna wrote:
> How can I know in a constructor code, whether it is safe
> to call the mutexes/conditions/...? I have no problem to revert
> to the polled mode in the startup code, if I know when
> it is safe to switch to the interrupt-driven one.

I ran into a very similar issue with my NAND driver work recently, though it
manifested as an assertion failure for me (I had CYGPKG_INFRA_DEBUG switched
on).

There are many ways to skin this particular cat. What I did (with Nick's
blessing) was to test whether
	(cyg_thread_self() == cyg_thread_idle_thread())

- if they are equal, then it's a pretty safe conclusion that the scheduler
has not yet started.


Ross

-- 
Embedded Software Engineer, eCosCentric Limited.
Barnwell House, Barnwell Drive, Cambridge CB5 8UU, UK.
Registered in England no. 4422071.                  www.ecoscentric.com

-- 
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]