score: Add and use _Thread_Get_unmapped_priority().

Add and use _Thread_Get_unmapped_real_priority().
This commit is contained in:
Sebastian Huber
2019-06-28 08:30:11 +02:00
parent c43071f523
commit 5803f3738f
7 changed files with 65 additions and 42 deletions

View File

@@ -34,7 +34,6 @@
#include <rtems.h> #include <rtems.h>
#include <rtems/rtems/tasksimpl.h> #include <rtems/rtems/tasksimpl.h>
#include <rtems/score/schedulerimpl.h>
#include <string.h> #include <string.h>
@@ -890,7 +889,7 @@ rtems_capture_task_start_priority (rtems_tcb* tcb)
static inline rtems_task_priority static inline rtems_task_priority
rtems_capture_task_real_priority (rtems_tcb* tcb) 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 static inline rtems_task_priority
rtems_capture_task_curr_priority (rtems_tcb* tcb) rtems_capture_task_curr_priority (rtems_tcb* tcb)
{ {
return SCHEDULER_PRIORITY_UNMAP (_Thread_Get_priority (tcb)); return _Thread_Get_unmapped_priority (tcb);
} }
/** /**

View File

@@ -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. * @brief Initializes the scheduler to the policy chosen by the user.
* *

View File

@@ -50,6 +50,36 @@ extern "C" {
*/ */
#define SCHEDULER_PRIORITY_APPEND_FLAG 1 #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. * @brief Initializes a node.
* *

View File

@@ -1600,6 +1600,34 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority(
return _Priority_Get_priority( &scheduler_node->Wait.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 * @brief Acquires the thread wait default lock inside a critical section
* (interrupts disabled). * (interrupts disabled).

View File

@@ -31,7 +31,6 @@
#include <rtems.h> #include <rtems.h>
#include <rtems/assoc.h> #include <rtems/assoc.h>
#include <rtems/score/schedulerimpl.h>
#include <rtems/score/threadimpl.h> #include <rtems/score/threadimpl.h>
#include <rtems/debugger/rtems-debugger-server.h> #include <rtems/debugger/rtems-debugger-server.h>
@@ -504,13 +503,13 @@ rtems_debugger_thread_is_stepping(rtems_id id, DB_UINT pc)
int int
rtems_debugger_thread_current_priority(rtems_debugger_thread* thread) 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 int
rtems_debugger_thread_real_priority(rtems_debugger_thread* thread) 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 int

View File

@@ -448,8 +448,8 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
" 0x%08" PRIx32 " | %-19s | %3" PRId64 " | %3" PRId64 " | ", " 0x%08" PRIx32 " | %-19s | %3" PRId64 " | %3" PRId64 " | ",
thread->Object.id, thread->Object.id,
name, name,
thread->Real_priority.priority, _Thread_Get_unmapped_real_priority(thread),
_Thread_Get_priority(thread)); _Thread_Get_unmapped_priority(thread));
usage = data->usage[i]; usage = data->usage[i];
current_usage = data->current_usage[i]; current_usage = data->current_usage[i];

View File

@@ -9,7 +9,6 @@
#include <rtems.h> #include <rtems.h>
#include <rtems/monitor.h> #include <rtems/monitor.h>
#include <rtems/rtems/tasksdata.h> #include <rtems/rtems/tasksdata.h>
#include <rtems/score/schedulerimpl.h>
#include <rtems/score/threadimpl.h> #include <rtems/score/threadimpl.h>
#include <rtems/score/threadqimpl.h> #include <rtems/score/threadqimpl.h>
@@ -112,9 +111,7 @@ rtems_monitor_task_canonical(
canonical_task->entry = rtems_thread->Start.Entry; canonical_task->entry = rtems_thread->Start.Entry;
canonical_task->stack = rtems_thread->Start.Initial_stack.area; canonical_task->stack = rtems_thread->Start.Initial_stack.area;
canonical_task->stack_size = rtems_thread->Start.Initial_stack.size; canonical_task->stack_size = rtems_thread->Start.Initial_stack.size;
canonical_task->priority = SCHEDULER_PRIORITY_UNMAP( canonical_task->priority = _Thread_Get_unmapped_priority( rtems_thread );
_Thread_Get_priority( rtems_thread )
);
canonical_task->events = api->Event.pending_events; canonical_task->events = api->Event.pending_events;
/* /*
* FIXME: make this optionally cpu_time_executed * FIXME: make this optionally cpu_time_executed