hw: set affinity of core threads

ref #1076
This commit is contained in:
Martin Stein 2014-03-07 15:15:15 +01:00 committed by Norman Feske
parent a586828844
commit 395e955756
3 changed files with 46 additions and 1 deletions

View File

@ -64,6 +64,11 @@ namespace Genode
*/
class Start_info;
/**
* Info that a core-thread creator hands out to Platform_thread::start
*/
class Core_start_info;
/**
* Memory region that is exclusive to every thread and known by the kernel
*/
@ -260,6 +265,32 @@ class Genode::Start_info
Native_capability utcb_ds() const { return _utcb_ds; }
};
class Genode::Core_start_info
{
private:
unsigned _processor_id;
public:
/**
* Set-up valid core startup-message
*
* \param processor_id kernel name of the processor to start on
*/
void init(unsigned const processor_id)
{
_processor_id = processor_id;
}
/***************
** Accessors **
***************/
unsigned processor_id() const { return _processor_id; }
};
class Genode::Native_utcb
{
private:
@ -279,6 +310,11 @@ class Genode::Native_utcb
Start_info * start_info() const { return (Start_info *)_data; }
Core_start_info * core_start_info() const
{
return (Core_start_info *)_data;
}
size_t size() const { return sizeof(_data)/sizeof(_data[0]); }
void * base() const { return (void *)_data; }

View File

@ -97,6 +97,9 @@ Platform_thread::Platform_thread(size_t const stack_size,
}
_utcb_virt = _utcb_phys;
/* set-up default start-info */
_utcb_virt->core_start_info()->init(Processor_driver::primary_id());
/* create kernel object */
_id = Kernel::new_thread(_kernel_thread, Kernel::Priority::MAX, _label);
if (!_id) {

View File

@ -85,10 +85,16 @@ void Thread_base::start()
/* provide thread ident at the aligned base of the stack */
*(Core_thread_id *)base = (Core_thread_id)this;
/* set affinity of thread */
Platform_thread * const platform_thread = _tid.platform_thread;
unsigned const processor_id = utcb()->core_start_info()->processor_id();
Affinity::Location location(processor_id, 0, 1, 1);
platform_thread->affinity(location);
/* start thread with stack pointer at the top of stack */
void * sp = (void *)((addr_t)base + size);
void * ip = (void *)&_thread_start;
if (_tid.platform_thread->start(ip, sp)) {
if (platform_thread->start(ip, sp)) {
PERR("failed to start thread");
alloc->free(base, size);
return;