[rtems commit] score: Add and use _Thread_Get_unmapped_priority().

Sebastian Huber sebh at rtems.org
Fri Jun 28 07:52:54 UTC 2019


Module:    rtems
Branch:    master
Commit:    5803f3738f8f97c2188bd36274e60602af515e7f
Changeset: http://git.rtems.org/rtems/commit/?id=5803f3738f8f97c2188bd36274e60602af515e7f

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jun 28 08:30:11 2019 +0200

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 7a313b3..c37d652 100644
--- a/cpukit/include/rtems/capture.h
+++ b/cpukit/include/rtems/capture.h
@@ -34,7 +34,6 @@
 
 #include <rtems.h>
 #include <rtems/rtems/tasksimpl.h>
-#include <rtems/score/schedulerimpl.h>
 
 #include <string.h>
 
@@ -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 bdd10b9..dcc81fc 100644
--- a/cpukit/include/rtems/score/schedulerimpl.h
+++ b/cpukit/include/rtems/score/schedulerimpl.h
@@ -40,36 +40,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.
  *
  * This routine 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 94cb3d6..675fb0e 100644
--- a/cpukit/include/rtems/score/schedulernodeimpl.h
+++ b/cpukit/include/rtems/score/schedulernodeimpl.h
@@ -51,6 +51,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.
  *
  * @param scheduler The scheduler for the initialization of @a node.
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index 490c7c8..2e41b80 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -1601,6 +1601,34 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_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 430ca4a..5ff249d 100644
--- a/cpukit/libdebugger/rtems-debugger-threads.c
+++ b/cpukit/libdebugger/rtems-debugger-threads.c
@@ -31,7 +31,6 @@
 
 #include <rtems.h>
 #include <rtems/assoc.h>
-#include <rtems/score/schedulerimpl.h>
 #include <rtems/score/threadimpl.h>
 
 #include <rtems/debugger/rtems-debugger-server.h>
@@ -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 c4bfa70..96e364b 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 e1126b6..bb2c49e 100644
--- a/cpukit/libmisc/monitor/mon-task.c
+++ b/cpukit/libmisc/monitor/mon-task.c
@@ -9,7 +9,6 @@
 #include <rtems.h>
 #include <rtems/monitor.h>
 #include <rtems/rtems/tasksdata.h>
-#include <rtems/score/schedulerimpl.h>
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/threadqimpl.h>
 
@@ -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



More information about the vc mailing list