From a5868288449ec6fb6afc1a64157035bdb1d6d2a0 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 6 Mar 2014 14:30:37 +0100 Subject: [PATCH] hw: consider affinity location in Platform_thread ref #1076 --- base-hw/src/core/include/platform.h | 5 +++++ base-hw/src/core/include/platform_thread.h | 15 +++++++++------ base-hw/src/core/platform_thread.cc | 19 ++++++++++++++++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/base-hw/src/core/include/platform.h b/base-hw/src/core/include/platform.h index d3931aeb3a..a33a89793f 100644 --- a/base-hw/src/core/include/platform.h +++ b/base-hw/src/core/include/platform.h @@ -120,6 +120,11 @@ namespace Genode { while (1) ; return 0; } + + Affinity::Space affinity_space() const + { + return Affinity::Space(PROCESSORS); + } }; } diff --git a/base-hw/src/core/include/platform_thread.h b/base-hw/src/core/include/platform_thread.h index bde51c14f3..ab77064cc1 100644 --- a/base-hw/src/core/include/platform_thread.h +++ b/base-hw/src/core/include/platform_thread.h @@ -63,6 +63,8 @@ namespace Genode { */ bool _main_thread; + Affinity::Location _location; + /** * Common construction part */ @@ -116,11 +118,10 @@ namespace Genode { /** * Run this thread * - * \param ip initial instruction pointer - * \param sp initial stack pointer - * \param cpu_id kernel name of targeted CPU + * \param ip initial instruction pointer + * \param sp initial stack pointer */ - int start(void * const ip, void * const sp, unsigned const cpu_id = 0); + int start(void * const ip, void * const sp); /** * Pause this thread @@ -154,13 +155,15 @@ namespace Genode { /** * Set the executing CPU for this thread + * + * \param location targeted location in affinity space */ - void affinity(Affinity::Location) { } + void affinity(Affinity::Location const & location); /** * Get the executing CPU for this thread */ - Affinity::Location affinity() { return Affinity::Location(); }; + Affinity::Location affinity() const; /** * Return the address space to which the thread is bound diff --git a/base-hw/src/core/platform_thread.cc b/base-hw/src/core/platform_thread.cc index 971af0145d..9a1dea3fac 100644 --- a/base-hw/src/core/platform_thread.cc +++ b/base-hw/src/core/platform_thread.cc @@ -160,8 +160,16 @@ int Platform_thread::join_pd(unsigned const pd_id, bool const main_thread, } -int Platform_thread::start(void * const ip, void * const sp, - unsigned int const cpu_id) +void Platform_thread::affinity(Affinity::Location const & location) +{ + _location = location; +} + + +Affinity::Location Platform_thread::affinity() const { return _location; } + + +int Platform_thread::start(void * const ip, void * const sp) { /* attach UTCB in case of a main thread */ if (_main_thread) { @@ -188,9 +196,14 @@ int Platform_thread::start(void * const ip, void * const sp, PERR("failed to initialize thread registers"); return -1; } + /* determine kernel name of targeted processor */ + unsigned processor_id; + if (_location.valid()) { processor_id = _location.xpos(); } + else { processor_id = Processor_driver::primary_id(); } + /* start executing new thread */ _utcb_phys->start_info()->init(_id, _utcb); - _tlb = Kernel::start_thread(_id, cpu_id, _pd_id, _utcb_phys); + _tlb = Kernel::start_thread(_id, processor_id, _pd_id, _utcb_phys); if (!_tlb) { PERR("failed to start thread"); return -1;