This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
eCos kernel for SMP platform
- From: "Christophe Coutand" <ccoutand at stmi dot com>
- To: <ecos-discuss at sourceware dot org>
- Date: Tue, 20 Apr 2010 04:10:06 -0700
- Subject: [ECOS] 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