[ECOS] CPU affinity in eCos

Nick Garnett nickg@ecoscentric.com
Fri Oct 16 10:46:00 GMT 2009

Archana Sastry <sastry.archana@gmail.com> writes:

> Hi,
> Thanks a lot Nick.
> I am actually working on a single processor system with two hardware
> threads. And I want to run my test on a particular processor and I
> want this to be deterministic; which would enable me to run the same
> test again on the same processor.

eCos has even less support for hyperthreading than it does for
SMP. The necessary instruction sequences needed to allow the hardware
threads to synchronize properly are not present in the code.

If you just want to run eCos on a single CPU, then the default non-SMP
version of eCos will do exactly that, since it will ignore the other
CPUs (real or virtual) and just run on the initial CPU.

> I am not sure if this would work, but I was wondering if the function
> void Cyg_Scheduler_Base::set_current_thread(Cyg_Thread *thread,
> HAL_SMP_CPU_TYPE cpu) would be of any use in this regard. This
> function is invoked in sched.cxx and only a thread is passed to it as
> an argument. However if I can somehow pass the HAL_SMP_CPU_TYPE cpiID,
> would that set my current thread in such a way that it can be run
> deterministically on that particular cpu (with ID = cpuID)?

That version of set_current_thread() just sets the pointer in the
current_thread array. It does nothing to actually schedule the thread
onto the given CPU. In fact, such behaviour would be totally at odds
with the general philosophy of SMP scheduling in eCos, where each CPU
is responsible for choosing the next thread for itself, and cannot
have a thread imposed upon it.

Nick Garnett                                       eCos Kernel Architect
eCosCentric Limited    http://www.eCosCentric.com       The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales:                         Reg No: 4422071

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