[ECOS] eCos kernel for SMP platform

Christophe Coutand ccoutand@stmi.com
Tue Apr 20 11:07:00 GMT 2010

Hi all,

I'm looking for some advice in the eCos kernel package. I think using
the statement Cyg_Thread *self = Cyg_Thread::self() without locking the
scheduler is not safe in SMP environment because this is not an atomic
operation and context might switch in the middle of the operation. As
copied below, most of the kernel synchronization mechanisms first get
the thread context before locking the scheduler. I can only see two ways
around it:
	1- Move the scheduler lock statement before the
Cyg_Thread::self() in every places required in the kernel
synchronization files
	2- or for SMP enable kernel include a scheduler lock/unlock
inside the inline definition of Cyg_Thread *Cyg_Thread::self() if that
is possible.
As anyone a preferred solution for this?

// Lock and/or wait

    CYG_REPORT_FUNCTYPE("returning %d");

    cyg_bool result = true;
    Cyg_Thread *self = Cyg_Thread::self();
    // Prevent preemption

    CYG_ASSERTCLASS( this, "Bad this pointer");


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