From 07aa56fffbec00ff4493090fd3bd22c2065175f4 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Wed, 20 Nov 2013 23:35:02 +0100 Subject: [PATCH] hw: re-add priority down-scaling This is a follow-up commit for "hw: beautify scheduling-priority code". ref #960 --- base-hw/src/core/include/platform_thread.h | 14 +++++++------- base-hw/src/core/kernel/configuration.h | 2 +- base-hw/src/core/platform_thread.cc | 12 +++++++----- base-hw/src/core/thread.cc | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/base-hw/src/core/include/platform_thread.h b/base-hw/src/core/include/platform_thread.h index 660262582..bde51c14f 100644 --- a/base-hw/src/core/include/platform_thread.h +++ b/base-hw/src/core/include/platform_thread.h @@ -78,21 +78,21 @@ namespace Genode { /** * Constructor for core threads * - * \param label debugging label * \param stack_size initial size of the stack * \param pd_id kernel name of targeted protection domain + * \param label debugging label */ - Platform_thread(const char * const label, size_t const stack_size, - unsigned const pd_id); + Platform_thread(size_t const stack_size, + unsigned const pd_id, const char * const label); /** * Constructor for threads outside of core * - * \param label debugging label - * \param priority processor-scheduling priority - * \param utcb core local pointer to userland thread-context + * \param label debugging label + * \param virt_prio unscaled processor-scheduling priority + * \param utcb core local pointer to userland thread-context */ - Platform_thread(const char * const label, unsigned const priority, + Platform_thread(const char * const label, unsigned const virt_prio, addr_t const utcb); /** diff --git a/base-hw/src/core/kernel/configuration.h b/base-hw/src/core/kernel/configuration.h index cd0cc4c84..fee68cd39 100644 --- a/base-hw/src/core/kernel/configuration.h +++ b/base-hw/src/core/kernel/configuration.h @@ -24,7 +24,7 @@ namespace Kernel MAX_SIGNAL_RECEIVERS = 256, MAX_SIGNAL_CONTEXTS = 2048, MAX_VMS = 4, - MAX_PRIORITY = 255, + MAX_PRIORITY = 128, }; } diff --git a/base-hw/src/core/platform_thread.cc b/base-hw/src/core/platform_thread.cc index 1baba9a90..2718f502b 100644 --- a/base-hw/src/core/platform_thread.cc +++ b/base-hw/src/core/platform_thread.cc @@ -73,9 +73,9 @@ Platform_thread::~Platform_thread() } -Platform_thread::Platform_thread(const char * const label, - size_t const stack_size, - unsigned const pd_id) +Platform_thread::Platform_thread(size_t const stack_size, + unsigned const pd_id, + const char * const label) : _stack_size(stack_size), _pd_id(pd_id), @@ -105,7 +105,7 @@ Platform_thread::Platform_thread(const char * const label, Platform_thread::Platform_thread(const char * const label, - unsigned const priority, + unsigned const virt_prio, addr_t const utcb) : _stack_size(0), @@ -132,7 +132,9 @@ Platform_thread::Platform_thread(const char * const label, _utcb_phys = (Native_utcb *)ram->phys_addr(_utcb); /* create kernel object */ - _id = Kernel::new_thread(_kernel_thread, priority, _label); + enum { MAX_PRIO = Kernel::Priority::MAX }; + auto const phys_prio = Cpu_session::scale_priority(MAX_PRIO, virt_prio); + _id = Kernel::new_thread(_kernel_thread, phys_prio, _label); if (!_id) { PERR("failed to create kernel object"); throw Cpu_session::Thread_creation_failed(); diff --git a/base-hw/src/core/thread.cc b/base-hw/src/core/thread.cc index a97bb96f1..8c985a44b 100644 --- a/base-hw/src/core/thread.cc +++ b/base-hw/src/core/thread.cc @@ -54,12 +54,12 @@ void Thread_base::_thread_start() } -Thread_base::Thread_base(const char *name, size_t stack_size) +Thread_base::Thread_base(const char * const label, size_t const stack_size) : _list_element(this) { _tid.platform_thread = new (platform()->core_mem_alloc()) - Platform_thread(name, stack_size, Kernel::core_id()); + Platform_thread(stack_size, Kernel::core_id(), label); }