From 0ddda795114e589cc50204d55f3f3e7142ebd7d6 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 8 Aug 2017 14:35:14 +0200 Subject: [PATCH] sel4: add priority support Issue #2451 --- repos/base-sel4/src/core/include/platform_thread.h | 1 + repos/base-sel4/src/core/include/thread_sel4.h | 9 ++++----- repos/base-sel4/src/core/platform_thread.cc | 10 ++++++++-- repos/base-sel4/src/core/thread_start.cc | 2 +- repos/base/run/thread.run | 1 - 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/repos/base-sel4/src/core/include/platform_thread.h b/repos/base-sel4/src/core/include/platform_thread.h index a8db2ff3d..94ce828ec 100644 --- a/repos/base-sel4/src/core/include/platform_thread.h +++ b/repos/base-sel4/src/core/include/platform_thread.h @@ -68,6 +68,7 @@ class Genode::Platform_thread : public List::Element enum { INITIAL_IPC_BUFFER_VIRT = 0x1000 }; Affinity::Location _location; + uint16_t _priority; public: diff --git a/repos/base-sel4/src/core/include/thread_sel4.h b/repos/base-sel4/src/core/include/thread_sel4.h index 9f3db874b..972fffa33 100644 --- a/repos/base-sel4/src/core/include/thread_sel4.h +++ b/repos/base-sel4/src/core/include/thread_sel4.h @@ -39,7 +39,7 @@ namespace Genode { Thread_info() { } - inline void init(addr_t const utcb_virt_addr); + inline void init(addr_t const utcb_virt_addr, unsigned const prio); inline void destruct(); }; @@ -52,7 +52,7 @@ namespace Genode { }; -void Genode::Thread_info::init(addr_t const utcb_virt_addr) +void Genode::Thread_info::init(addr_t const utcb_virt_addr, unsigned const prio) { Platform &platform = *platform_specific(); Range_allocator &phys_alloc = *platform.ram_alloc(); @@ -99,9 +99,8 @@ void Genode::Thread_info::init(addr_t const utcb_virt_addr) } /* set scheduling priority */ - enum { PRIORITY_MAX = 0xff }; - seL4_TCB_SetMCPriority(tcb_sel.value(), PRIORITY_MAX); - seL4_TCB_SetPriority(tcb_sel.value(), PRIORITY_MAX); + seL4_TCB_SetMCPriority(tcb_sel.value(), prio); + seL4_TCB_SetPriority(tcb_sel.value(), prio); } diff --git a/repos/base-sel4/src/core/platform_thread.cc b/repos/base-sel4/src/core/platform_thread.cc index 8a690646a..5ab4ac0c4 100644 --- a/repos/base-sel4/src/core/platform_thread.cc +++ b/repos/base-sel4/src/core/platform_thread.cc @@ -220,10 +220,16 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned priority, _name(name), _utcb(utcb), _pager_obj_sel(platform_specific()->core_sel_alloc().alloc()), - _location(location) + _location(location), + _priority(Cpu_session::scale_priority(CONFIG_NUM_PRIORITIES, priority)) { - _info.init(_utcb ? _utcb : INITIAL_IPC_BUFFER_VIRT); + static_assert(CONFIG_NUM_PRIORITIES == 256, " unknown priority configuration"); + + if (_priority > 0) + _priority -= 1; + + _info.init(_utcb ? _utcb : INITIAL_IPC_BUFFER_VIRT, _priority); platform_thread_registry().insert(*this); } diff --git a/repos/base-sel4/src/core/thread_start.cc b/repos/base-sel4/src/core/thread_start.cc index 04099d6d1..15a5cd1d3 100644 --- a/repos/base-sel4/src/core/thread_start.cc +++ b/repos/base-sel4/src/core/thread_start.cc @@ -38,7 +38,7 @@ void Thread::_init_platform_thread(size_t, Type type) } Thread_info thread_info; - thread_info.init(utcb_virt_addr); + thread_info.init(utcb_virt_addr, CONFIG_NUM_PRIORITIES - 1); if (!map_local(thread_info.ipc_buffer_phys, utcb_virt_addr, 1)) { error(__func__, ": could not map IPC buffer " diff --git a/repos/base/run/thread.run b/repos/base/run/thread.run index 54b96bcb2..7c5f9ec78 100644 --- a/repos/base/run/thread.run +++ b/repos/base/run/thread.run @@ -19,7 +19,6 @@ proc pause_resume_supported { } { # proc prio_supported { } { if {[have_spec hw]} { return false } - if {[have_spec sel4]} { return false } if {[have_spec linux]} { return false } if {[have_spec fiasco]} { return false } return true