From 5803f3738f8f97c2188bd36274e60602af515e7f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 28 Jun 2019 08:30:11 +0200 Subject: score: Add and use _Thread_Get_unmapped_priority(). Add and use _Thread_Get_unmapped_real_priority(). --- cpukit/include/rtems/capture.h | 5 ++--- cpukit/include/rtems/score/schedulerimpl.h | 30 -------------------------- cpukit/include/rtems/score/schedulernodeimpl.h | 30 ++++++++++++++++++++++++++ cpukit/include/rtems/score/threadimpl.h | 28 ++++++++++++++++++++++++ cpukit/libdebugger/rtems-debugger-threads.c | 5 ++--- cpukit/libmisc/cpuuse/cpuusagetop.c | 4 ++-- cpukit/libmisc/monitor/mon-task.c | 5 +---- 7 files changed, 65 insertions(+), 42 deletions(-) diff --git a/cpukit/include/rtems/capture.h b/cpukit/include/rtems/capture.h index 7a313b3b8b..c37d652211 100644 --- a/cpukit/include/rtems/capture.h +++ b/cpukit/include/rtems/capture.h @@ -34,7 +34,6 @@ #include #include -#include #include @@ -890,7 +889,7 @@ rtems_capture_task_start_priority (rtems_tcb* tcb) static inline rtems_task_priority rtems_capture_task_real_priority (rtems_tcb* tcb) { - return SCHEDULER_PRIORITY_UNMAP (tcb->Real_priority.priority); + return _Thread_Get_unmapped_real_priority (tcb); } /** @@ -905,7 +904,7 @@ rtems_capture_task_real_priority (rtems_tcb* tcb) static inline rtems_task_priority rtems_capture_task_curr_priority (rtems_tcb* tcb) { - return SCHEDULER_PRIORITY_UNMAP (_Thread_Get_priority (tcb)); + return _Thread_Get_unmapped_priority (tcb); } /** diff --git a/cpukit/include/rtems/score/schedulerimpl.h b/cpukit/include/rtems/score/schedulerimpl.h index bdd10b9535..dcc81fcbbf 100644 --- a/cpukit/include/rtems/score/schedulerimpl.h +++ b/cpukit/include/rtems/score/schedulerimpl.h @@ -39,36 +39,6 @@ extern "C" { * @{ */ -/** - * @brief Maps a priority value to support the append indicator. - */ -#define SCHEDULER_PRIORITY_MAP( priority ) ( ( priority ) << 1 ) - -/** - * @brief Returns the plain priority value. - */ -#define SCHEDULER_PRIORITY_UNMAP( priority ) ( ( priority ) >> 1 ) - -/** - * @brief Clears the priority append indicator bit. - */ -#define SCHEDULER_PRIORITY_PURIFY( priority ) \ - ( ( priority ) & ~( (Priority_Control) SCHEDULER_PRIORITY_APPEND_FLAG ) ) - -/** - * @brief Returns the priority control with the append indicator bit set. - */ -#define SCHEDULER_PRIORITY_APPEND( priority ) \ - ( ( priority ) | SCHEDULER_PRIORITY_APPEND_FLAG ) - -/** - * @brief Returns true, if the item should be appended to its priority group, - * otherwise returns false and the item should be prepended to its priority - * group. - */ -#define SCHEDULER_PRIORITY_IS_APPEND( priority ) \ - ( ( ( priority ) & SCHEDULER_PRIORITY_APPEND_FLAG ) != 0 ) - /** * @brief Initializes the scheduler to the policy chosen by the user. * diff --git a/cpukit/include/rtems/score/schedulernodeimpl.h b/cpukit/include/rtems/score/schedulernodeimpl.h index 94cb3d6270..675fb0efda 100644 --- a/cpukit/include/rtems/score/schedulernodeimpl.h +++ b/cpukit/include/rtems/score/schedulernodeimpl.h @@ -50,6 +50,36 @@ extern "C" { */ #define SCHEDULER_PRIORITY_APPEND_FLAG 1 +/** + * @brief Maps a priority value to support the append indicator. + */ +#define SCHEDULER_PRIORITY_MAP( priority ) ( ( priority ) << 1 ) + +/** + * @brief Returns the plain priority value. + */ +#define SCHEDULER_PRIORITY_UNMAP( priority ) ( ( priority ) >> 1 ) + +/** + * @brief Clears the priority append indicator bit. + */ +#define SCHEDULER_PRIORITY_PURIFY( priority ) \ + ( ( priority ) & ~( (Priority_Control) SCHEDULER_PRIORITY_APPEND_FLAG ) ) + +/** + * @brief Returns the priority control with the append indicator bit set. + */ +#define SCHEDULER_PRIORITY_APPEND( priority ) \ + ( ( priority ) | SCHEDULER_PRIORITY_APPEND_FLAG ) + +/** + * @brief Returns true, if the item should be appended to its priority group, + * otherwise returns false and the item should be prepended to its priority + * group. + */ +#define SCHEDULER_PRIORITY_IS_APPEND( priority ) \ + ( ( ( priority ) & SCHEDULER_PRIORITY_APPEND_FLAG ) != 0 ) + /** * @brief Initializes a node. * diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h index 490c7c83e0..2e41b80bd4 100644 --- a/cpukit/include/rtems/score/threadimpl.h +++ b/cpukit/include/rtems/score/threadimpl.h @@ -1600,6 +1600,34 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority( return _Priority_Get_priority( &scheduler_node->Wait.Priority ); } +/** + * @brief Returns the unmapped priority of the thread. + * + * @param the_thread The thread of which to get the unmapped priority. + * + * @return The unmapped priority of the thread. + */ +RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_priority( + const Thread_Control *the_thread +) +{ + return SCHEDULER_PRIORITY_UNMAP( _Thread_Get_priority( the_thread ) ); +} + +/** + * @brief Returns the unmapped real priority of the thread. + * + * @param the_thread The thread of which to get the unmapped real priority. + * + * @return The unmapped real priority of the thread. + */ +RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_real_priority( + const Thread_Control *the_thread +) +{ + return SCHEDULER_PRIORITY_UNMAP( the_thread->Real_priority.priority ); +} + /** * @brief Acquires the thread wait default lock inside a critical section * (interrupts disabled). diff --git a/cpukit/libdebugger/rtems-debugger-threads.c b/cpukit/libdebugger/rtems-debugger-threads.c index 430ca4a7cf..5ff249dc07 100644 --- a/cpukit/libdebugger/rtems-debugger-threads.c +++ b/cpukit/libdebugger/rtems-debugger-threads.c @@ -31,7 +31,6 @@ #include #include -#include #include #include @@ -504,13 +503,13 @@ rtems_debugger_thread_is_stepping(rtems_id id, DB_UINT pc) int rtems_debugger_thread_current_priority(rtems_debugger_thread* thread) { - return SCHEDULER_PRIORITY_UNMAP(_Thread_Get_priority(thread->tcb)); + return _Thread_Get_unmapped_priority(thread->tcb); } int rtems_debugger_thread_real_priority(rtems_debugger_thread* thread) { - return SCHEDULER_PRIORITY_UNMAP(thread->tcb->Real_priority.priority); + return _Thread_Get_unmapped_real_priority(thread->tcb); } int diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c b/cpukit/libmisc/cpuuse/cpuusagetop.c index c4bfa704d1..96e364bf93 100644 --- a/cpukit/libmisc/cpuuse/cpuusagetop.c +++ b/cpukit/libmisc/cpuuse/cpuusagetop.c @@ -448,8 +448,8 @@ rtems_cpuusage_top_thread (rtems_task_argument arg) " 0x%08" PRIx32 " | %-19s | %3" PRId64 " | %3" PRId64 " | ", thread->Object.id, name, - thread->Real_priority.priority, - _Thread_Get_priority(thread)); + _Thread_Get_unmapped_real_priority(thread), + _Thread_Get_unmapped_priority(thread)); usage = data->usage[i]; current_usage = data->current_usage[i]; diff --git a/cpukit/libmisc/monitor/mon-task.c b/cpukit/libmisc/monitor/mon-task.c index e1126b6457..bb2c49e77f 100644 --- a/cpukit/libmisc/monitor/mon-task.c +++ b/cpukit/libmisc/monitor/mon-task.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -112,9 +111,7 @@ rtems_monitor_task_canonical( canonical_task->entry = rtems_thread->Start.Entry; canonical_task->stack = rtems_thread->Start.Initial_stack.area; canonical_task->stack_size = rtems_thread->Start.Initial_stack.size; - canonical_task->priority = SCHEDULER_PRIORITY_UNMAP( - _Thread_Get_priority( rtems_thread ) - ); + canonical_task->priority = _Thread_Get_unmapped_priority( rtems_thread ); canonical_task->events = api->Event.pending_events; /* * FIXME: make this optionally cpu_time_executed -- cgit v1.2.3