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]

eCos kernel for SMP platform


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_bool
Cyg_Mutex::lock(void)
{
    CYG_REPORT_FUNCTYPE("returning %d");

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

    CYG_ASSERTCLASS( this, "Bad this pointer");
    
    CYG_INSTRUMENT_MUTEX(LOCK, this, 0);
...

Regards,
Christophe

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