[PATCH 1/2] score: Replace priority prepend it with flags

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Aug 10 14:34:19 UTC 2021


Use an enum instead of a boolean to indicated if a priority should be
appended or prepended to its priority group.  This makes the code more
expressive and it a bit more efficient since a branch in
_Scheduler_Node_set_priority() is avoided.
---
 cpukit/include/rtems/posix/muteximpl.h        |  2 +-
 cpukit/include/rtems/score/coremuteximpl.h    |  2 +-
 cpukit/include/rtems/score/priorityimpl.h     | 39 +++++++++++++------
 cpukit/include/rtems/score/schedulerimpl.h    | 12 +++++-
 .../include/rtems/score/schedulernodeimpl.h   | 26 ++++++-------
 cpukit/include/rtems/score/threadimpl.h       | 20 +++++-----
 cpukit/posix/src/pthreadsetschedparam.c       |  2 +-
 cpukit/posix/src/pthreadsetschedprio.c        |  2 +-
 cpukit/rtems/src/tasksetpriority.c            |  2 +-
 cpukit/score/src/scheduleredfreleasejob.c     |  2 +-
 cpukit/score/src/threadchangepriority.c       | 36 ++++++++++-------
 cpukit/score/src/threadqops.c                 | 18 ++++-----
 cpukit/score/src/threadrestart.c              |  4 +-
 testsuites/smptests/smpscheduler03/test.c     | 33 +++++++++-------
 14 files changed, 116 insertions(+), 84 deletions(-)

diff --git a/cpukit/include/rtems/posix/muteximpl.h b/cpukit/include/rtems/posix/muteximpl.h
index 4a475aac5e..4908f8f259 100644
--- a/cpukit/include/rtems/posix/muteximpl.h
+++ b/cpukit/include/rtems/posix/muteximpl.h
@@ -273,7 +273,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_priority(
       owner,
       &the_mutex->Priority_ceiling,
       priority_ceiling,
-      false,
+      PRIORITY_APPEND_FLAG,
       queue_context
     );
     _Thread_Wait_release( owner, queue_context );
diff --git a/cpukit/include/rtems/score/coremuteximpl.h b/cpukit/include/rtems/score/coremuteximpl.h
index b281c52889..c97ffcf351 100644
--- a/cpukit/include/rtems/score/coremuteximpl.h
+++ b/cpukit/include/rtems/score/coremuteximpl.h
@@ -377,7 +377,7 @@ RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority(
       owner,
       &the_mutex->Priority_ceiling,
       priority_ceiling,
-      false,
+      PRIORITY_APPEND_FLAG,
       &queue_context
     );
     _Thread_Wait_release_critical( owner, &queue_context );
diff --git a/cpukit/include/rtems/score/priorityimpl.h b/cpukit/include/rtems/score/priorityimpl.h
index 7a14ec97b8..4958bfc77f 100644
--- a/cpukit/include/rtems/score/priorityimpl.h
+++ b/cpukit/include/rtems/score/priorityimpl.h
@@ -37,6 +37,24 @@ extern "C" {
  * @{
  */
 
+ /**
+  * @brief The priority flags indicate if the priority should be appended or
+  *   prepended to its priority group.
+  */
+typedef enum {
+  /**
+   * @brief Priority prepend flag indicates that the priority should be prepended
+   *   to its priority group.
+   */
+  PRIORITY_PREPEND_FLAG = 0,
+
+  /**
+   * @brief Priority append flag indicates that the priority should be appended
+   *   to its priority group.
+   */
+  PRIORITY_APPEND_FLAG = 1
+} Priority_Flags;
+
 /**
  * @brief Initializes the priority actions empty.
  *
@@ -465,7 +483,7 @@ typedef void ( *Priority_Add_handler )(
 
 typedef void ( *Priority_Change_handler )(
   Priority_Aggregation *aggregation,
-  bool                  prepend_it,
+  Priority_Flags        flags,
   Priority_Actions     *actions,
   void                 *arg
 );
@@ -482,19 +500,19 @@ typedef void ( *Priority_Remove_handler )(
  * This method does nothing.
  *
  * @param aggregation Is ignored by the method.
- * @param prepend_it Is ignored by the method.
+ * @param flags Is ignored by the method.
  * @param actions Is ignored by the method.
  * @param arg Is ignored by the method.
  */
 RTEMS_INLINE_ROUTINE void _Priority_Change_nothing(
   Priority_Aggregation *aggregation,
-  bool                  prepend_it,
+  Priority_Flags        flags,
   Priority_Actions     *actions,
   void                 *arg
 )
 {
   (void) aggregation;
-  (void) prepend_it;
+  (void) flags;
   (void) actions;
   (void) arg;
 }
@@ -547,7 +565,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Non_empty_insert(
 
   if ( is_new_minimum ) {
     aggregation->Node.priority = node->priority;
-    ( *change )( aggregation, false, actions, arg );
+    ( *change )( aggregation, PRIORITY_APPEND_FLAG, actions, arg );
   }
 }
 
@@ -619,7 +637,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Extract(
 
     if ( node->priority < min->priority ) {
       aggregation->Node.priority = min->priority;
-      ( *change )( aggregation, true, actions, arg );
+      ( *change )( aggregation, PRIORITY_PREPEND_FLAG, actions, arg );
     }
   }
 }
@@ -654,7 +672,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Extract_non_empty(
 
   if ( node->priority < min->priority ) {
     aggregation->Node.priority = min->priority;
-    ( *change )( aggregation, true, actions, arg );
+    ( *change )( aggregation, PRIORITY_PREPEND_FLAG, actions, arg );
   }
 }
 
@@ -666,8 +684,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Extract_non_empty(
  *
  * @param[in, out] aggregation The aggregation to change the node in.
  * @param node The node that has a new priority and will be reinserted in the aggregation.
- * @param prepend_it Indicates whether @a change should prepend if the minimal priority is
- *      incorrectly set after the change.
+ * @param flags The set of flags which may be used by @ change.
  * @param actions The actions for the case that the minimal priority is incorrectly set
  *      after the change.
  * @param change Is called if the minimal priority is incorrectly set after the change.
@@ -676,7 +693,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Extract_non_empty(
 RTEMS_INLINE_ROUTINE void _Priority_Changed(
   Priority_Aggregation    *aggregation,
   Priority_Node           *node,
-  bool                     prepend_it,
+  Priority_Flags           flags,
   Priority_Actions        *actions,
   Priority_Change_handler  change,
   void                    *arg
@@ -695,7 +712,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Changed(
 
   if ( min->priority != aggregation->Node.priority ) {
     aggregation->Node.priority = min->priority;
-    ( *change )( aggregation, prepend_it, actions, arg );
+    ( *change )( aggregation, flags, actions, arg );
   }
 }
 
diff --git a/cpukit/include/rtems/score/schedulerimpl.h b/cpukit/include/rtems/score/schedulerimpl.h
index 595d6291b4..586f9e0ec8 100644
--- a/cpukit/include/rtems/score/schedulerimpl.h
+++ b/cpukit/include/rtems/score/schedulerimpl.h
@@ -1388,7 +1388,11 @@ RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
       &new_scheduler_node->Thread.Scheduler_node.Chain
     );
 
-    _Scheduler_Node_set_priority( new_scheduler_node, priority, false );
+    _Scheduler_Node_set_priority(
+      new_scheduler_node,
+      priority,
+      PRIORITY_APPEND_FLAG
+    );
 
     if ( _States_Is_ready( current_state ) ) {
       _Scheduler_Unblock( the_thread );
@@ -1398,7 +1402,11 @@ RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
   }
 #endif
 
-  _Scheduler_Node_set_priority( new_scheduler_node, priority, false );
+  _Scheduler_Node_set_priority(
+    new_scheduler_node,
+    priority,
+    PRIORITY_APPEND_FLAG
+  );
   _Scheduler_Update_priority( the_thread );
   return STATUS_SUCCESSFUL;
 }
diff --git a/cpukit/include/rtems/score/schedulernodeimpl.h b/cpukit/include/rtems/score/schedulernodeimpl.h
index 5d6f795912..3da29bb37e 100644
--- a/cpukit/include/rtems/score/schedulernodeimpl.h
+++ b/cpukit/include/rtems/score/schedulernodeimpl.h
@@ -46,12 +46,6 @@ extern "C" {
 #define SCHEDULER_NODE_OF_WAIT_PRIORITY( node ) \
   RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority )
 
-/**
- * @brief Priority append indicator for the priority control used for the
- * scheduler node priority.
- */
-#define SCHEDULER_PRIORITY_APPEND_FLAG 1
-
 /**
  * @brief Maps a priority value to support the append indicator.
  */
@@ -66,13 +60,13 @@ extern "C" {
  * @brief Clears the priority append indicator bit.
  */
 #define SCHEDULER_PRIORITY_PURIFY( priority )  \
-  ( ( priority ) & ~( (Priority_Control) SCHEDULER_PRIORITY_APPEND_FLAG ) )
+  ( ( priority ) & ~( (Priority_Control) PRIORITY_APPEND_FLAG ) )
 
 /**
  * @brief Returns the priority control with the append indicator bit set.
  */
 #define SCHEDULER_PRIORITY_APPEND( priority )  \
-  ( ( priority ) | SCHEDULER_PRIORITY_APPEND_FLAG )
+  ( ( priority ) | ( (Priority_Control) PRIORITY_APPEND_FLAG ) )
 
 /**
  * @brief Returns true, if the item should be appended to its priority group,
@@ -80,7 +74,7 @@ extern "C" {
  * group.
  */
 #define SCHEDULER_PRIORITY_IS_APPEND( priority ) \
-  ( ( ( priority ) & SCHEDULER_PRIORITY_APPEND_FLAG ) != 0 )
+  ( ( ( priority ) & ( (Priority_Control) PRIORITY_APPEND_FLAG ) ) != 0 )
 
 /**
  * @brief Initializes a node.
@@ -173,14 +167,17 @@ RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority(
 /**
  * @brief Sets the priority of the node.
  *
- * @param[in, out] node The node to set the priority of.
- * @param new_priority The new priority for @a node.
- * @param prepend_it Indicates whether the new priority should be prepended.
+ * @param[in, out] node is the scheduler node.
+ *
+ * @param new_priority is the priority to set.
+ *
+ * @param flags is a set of flags, see #PRIORITY_APPEND_FLAG and
+ *   #PRIORITY_PREPEND_FLAG.
  */
 RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority(
   Scheduler_Node   *node,
   Priority_Control  new_priority,
-  bool              prepend_it
+  Priority_Flags    flags
 )
 {
 #if defined(RTEMS_SMP)
@@ -189,8 +186,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority(
   seq = _SMP_sequence_lock_Write_begin( &node->Priority.Lock );
 #endif
 
-  new_priority |= ( prepend_it ? 0 : SCHEDULER_PRIORITY_APPEND_FLAG );
-  node->Priority.value = new_priority;
+  node->Priority.value = new_priority | ( (Priority_Control) flags );
 
 #if defined(RTEMS_SMP)
   _SMP_sequence_lock_Write_end( &node->Priority.Lock, seq );
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index 3682e865f6..6f355de1d6 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -691,9 +691,10 @@ void _Thread_Priority_remove(
  *
  * @param the_thread The thread.
  * @param[out] priority_node The thread priority node to change.
- * @param prepend_it In case this is true, then the thread is prepended to
- *   its priority group in its home scheduler instance, otherwise it is
- *   appended.
+ * @param priority_flags The priority flags indicate for example if the thread
+ *   is appended or prepended to its priority group in its home scheduler
+ *   instance, see #PRIORITY_APPEND_FLAG and
+ *   #PRIORITY_PREPEND_FLAG.
  * @param queue_context The thread queue context to return an updated set of
  *   threads for _Thread_Priority_update().  The thread queue context must be
  *   initialized via _Thread_queue_Context_clear_priority_updates() before a
@@ -704,7 +705,7 @@ void _Thread_Priority_remove(
 void _Thread_Priority_changed(
   Thread_Control       *the_thread,
   Priority_Node        *priority_node,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Thread_queue_Context *queue_context
 );
 
@@ -718,9 +719,10 @@ void _Thread_Priority_changed(
  * @param[out] priority_node The thread priority node to change.
  * @param new_priority The new thread priority value of the thread priority
  *   node to change.
- * @param prepend_it In case this is true, then the thread is prepended to
- *   its priority group in its home scheduler instance, otherwise it is
- *   appended.
+ * @param priority_flags The priority flags indicate for example if the thread
+ *   is appended or prepended to its priority group in its home scheduler
+ *   instance, see #PRIORITY_APPEND_FLAG and
+ *   #PRIORITY_PREPEND_FLAG.
  * @param queue_context The thread queue context to return an updated set of
  *   threads for _Thread_Priority_update().  The thread queue context must be
  *   initialized via _Thread_queue_Context_clear_priority_updates() before a
@@ -732,7 +734,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Priority_change(
   Thread_Control       *the_thread,
   Priority_Node        *priority_node,
   Priority_Control      new_priority,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Thread_queue_Context *queue_context
 )
 {
@@ -740,7 +742,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Priority_change(
   _Thread_Priority_changed(
     the_thread,
     priority_node,
-    prepend_it,
+    priority_flags,
     queue_context
   );
 }
diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c
index e9be24b417..99506f8228 100644
--- a/cpukit/posix/src/pthreadsetschedparam.c
+++ b/cpukit/posix/src/pthreadsetschedparam.c
@@ -96,7 +96,7 @@ static int _POSIX_Set_sched_param(
     _Thread_Priority_changed(
       the_thread,
       &the_thread->Real_priority,
-      false,
+      PRIORITY_APPEND_FLAG,
       queue_context
     );
 #if defined(RTEMS_POSIX_API)
diff --git a/cpukit/posix/src/pthreadsetschedprio.c b/cpukit/posix/src/pthreadsetschedprio.c
index 72c7dab273..d291138090 100644
--- a/cpukit/posix/src/pthreadsetschedprio.c
+++ b/cpukit/posix/src/pthreadsetschedprio.c
@@ -49,7 +49,7 @@ int pthread_setschedprio( pthread_t thread, int prio )
     the_thread,
     &the_thread->Real_priority,
     new_priority,
-    true,
+    PRIORITY_PREPEND_FLAG,
     &queue_context
   );
 
diff --git a/cpukit/rtems/src/tasksetpriority.c b/cpukit/rtems/src/tasksetpriority.c
index 50d1bc156c..a90393aa9f 100644
--- a/cpukit/rtems/src/tasksetpriority.c
+++ b/cpukit/rtems/src/tasksetpriority.c
@@ -50,7 +50,7 @@ static rtems_status_code _RTEMS_tasks_Set_priority(
     the_thread,
     &the_thread->Real_priority,
     core_new_priority,
-    false,
+    PRIORITY_APPEND_FLAG,
     queue_context
   );
   cpu_self = _Thread_queue_Dispatch_disable( queue_context );
diff --git a/cpukit/score/src/scheduleredfreleasejob.c b/cpukit/score/src/scheduleredfreleasejob.c
index 443fdaeed5..5236ab076a 100644
--- a/cpukit/score/src/scheduleredfreleasejob.c
+++ b/cpukit/score/src/scheduleredfreleasejob.c
@@ -66,7 +66,7 @@ void _Scheduler_EDF_Release_job(
     _Thread_Priority_changed(
       the_thread,
       priority_node,
-      false,
+      PRIORITY_APPEND_FLAG,
       queue_context
     );
   } else {
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index 13e9147916..70fac88e73 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -31,13 +31,13 @@
 
 static void _Thread_Set_scheduler_node_priority(
   Priority_Aggregation *priority_aggregation,
-  bool                  prepend_it
+  Priority_Flags        priority_flags
 )
 {
   _Scheduler_Node_set_priority(
     SCHEDULER_NODE_OF_WAIT_PRIORITY_NODE( priority_aggregation ),
     _Priority_Get_priority( priority_aggregation ),
-    prepend_it
+    priority_flags
   );
 }
 
@@ -55,7 +55,10 @@ static void _Thread_Priority_action_add(
   the_thread = arg;
 
   _Thread_Scheduler_add_wait_node( the_thread, scheduler_node );
-  _Thread_Set_scheduler_node_priority( priority_aggregation, false );
+  _Thread_Set_scheduler_node_priority(
+    priority_aggregation,
+    PRIORITY_APPEND_FLAG
+  );
   _Priority_Set_action_type( priority_aggregation, PRIORITY_ACTION_ADD );
   _Priority_Actions_add( priority_actions, priority_aggregation );
 }
@@ -73,7 +76,10 @@ static void _Thread_Priority_action_remove(
   the_thread = arg;
 
   _Thread_Scheduler_remove_wait_node( the_thread, scheduler_node );
-  _Thread_Set_scheduler_node_priority( priority_aggregation, true );
+  _Thread_Set_scheduler_node_priority(
+    priority_aggregation,
+    PRIORITY_PREPEND_FLAG
+  );
   _Priority_Set_action_type( priority_aggregation, PRIORITY_ACTION_REMOVE );
   _Priority_Actions_add( priority_actions, priority_aggregation );
 }
@@ -81,12 +87,12 @@ static void _Thread_Priority_action_remove(
 
 static void _Thread_Priority_action_change(
   Priority_Aggregation *priority_aggregation,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Priority_Actions     *priority_actions,
   void                 *arg
 )
 {
-  _Thread_Set_scheduler_node_priority( priority_aggregation, prepend_it );
+  _Thread_Set_scheduler_node_priority( priority_aggregation, priority_flags );
 #if defined(RTEMS_SMP) || defined(RTEMS_DEBUG)
   _Priority_Set_action_type( priority_aggregation, PRIORITY_ACTION_CHANGE );
 #endif
@@ -97,7 +103,7 @@ static void _Thread_Priority_do_perform_actions(
   Thread_Control                *the_thread,
   Thread_queue_Queue            *queue,
   const Thread_queue_Operations *operations,
-  bool                           prepend_it,
+  Priority_Flags                 priority_flags,
   Thread_queue_Context          *queue_context
 )
 {
@@ -162,7 +168,7 @@ static void _Thread_Priority_do_perform_actions(
         _Priority_Changed(
           priority_aggregation,
           priority_action_node,
-          prepend_it,
+          priority_flags,
           &queue_context->Priority.Actions,
           _Thread_Priority_action_change,
           NULL
@@ -214,7 +220,7 @@ void _Thread_Priority_perform_actions(
       the_thread,
       queue,
       the_thread->Wait.operations,
-      false,
+      PRIORITY_APPEND_FLAG,
       queue_context
     );
 
@@ -244,7 +250,7 @@ static void _Thread_Priority_apply(
   Thread_Control       *the_thread,
   Priority_Node        *priority_action_node,
   Thread_queue_Context *queue_context,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Priority_Action_type  priority_action_type
 )
 {
@@ -263,7 +269,7 @@ static void _Thread_Priority_apply(
     the_thread,
     queue,
     the_thread->Wait.operations,
-    prepend_it,
+    priority_flags,
     queue_context
   );
 
@@ -288,7 +294,7 @@ void _Thread_Priority_add(
     the_thread,
     priority_node,
     queue_context,
-    false,
+    PRIORITY_APPEND_FLAG,
     PRIORITY_ACTION_ADD
   );
 }
@@ -303,7 +309,7 @@ void _Thread_Priority_remove(
     the_thread,
     priority_node,
     queue_context,
-    true,
+    PRIORITY_PREPEND_FLAG,
     PRIORITY_ACTION_REMOVE
   );
 }
@@ -311,7 +317,7 @@ void _Thread_Priority_remove(
 void _Thread_Priority_changed(
   Thread_Control       *the_thread,
   Priority_Node        *priority_node,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Thread_queue_Context *queue_context
 )
 {
@@ -319,7 +325,7 @@ void _Thread_Priority_changed(
     the_thread,
     priority_node,
     queue_context,
-    prepend_it,
+    priority_flags,
     PRIORITY_ACTION_CHANGE
   );
 }
diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c
index d6ba9dad57..84130665de 100644
--- a/cpukit/score/src/threadqops.c
+++ b/cpukit/score/src/threadqops.c
@@ -700,7 +700,7 @@ static void _Thread_queue_Priority_inherit_do_priority_actions_remove(
 
 static void _Thread_queue_Priority_inherit_do_priority_actions_change(
   Priority_Aggregation *priority_aggregation,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Priority_Actions     *priority_actions,
   void                 *arg
 )
@@ -787,7 +787,7 @@ static void _Thread_queue_Priority_inherit_priority_actions(
         _Priority_Changed(
           &priority_queue->Queue,
           &scheduler_node->Wait.Priority.Node,
-          false,
+          PRIORITY_APPEND_FLAG,
           priority_actions,
           _Thread_queue_Priority_inherit_do_priority_actions_change,
           scheduler_node_of_owner
@@ -884,7 +884,7 @@ static void _Thread_queue_Priority_inherit_do_initialize(
 
 static void _Thread_queue_Priority_inherit_do_enqueue_change(
   Priority_Aggregation *priority_aggregation,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Priority_Actions     *priority_actions,
   void                 *arg
 )
@@ -1079,7 +1079,7 @@ static void _Thread_queue_Priority_inherit_do_extract_remove(
 
 static void _Thread_queue_Priority_inherit_do_extract_change(
   Priority_Aggregation *priority_aggregation,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Priority_Actions     *priority_actions,
   void                 *arg
 )
@@ -1231,7 +1231,7 @@ static void _Thread_queue_Priority_inherit_do_surrender_add(
   _Scheduler_Node_set_priority(
     scheduler_node,
     _Priority_Get_priority( priority_aggregation ),
-    false
+    PRIORITY_APPEND_FLAG
   );
 }
 
@@ -1254,7 +1254,7 @@ static void _Thread_queue_Priority_inherit_do_surrender_remove(
 
 static void _Thread_queue_Priority_inherit_do_surrender_change(
   Priority_Aggregation *priority_aggregation,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Priority_Actions     *priority_actions,
   void                 *arg
 )
@@ -1270,14 +1270,14 @@ static void _Thread_queue_Priority_inherit_do_surrender_change(
   _Scheduler_Node_set_priority(
     SCHEDULER_NODE_OF_WAIT_PRIORITY( priority_aggregation ),
     _Priority_Get_priority( priority_aggregation ),
-    prepend_it
+    priority_flags
   );
 }
 
 #if defined(RTEMS_SMP)
 static void _Thread_queue_Priority_inherit_do_surrender_change_2(
   Priority_Aggregation *priority_aggregation,
-  bool                  prepend_it,
+  Priority_Flags        priority_flags,
   Priority_Actions     *priority_actions,
   void                 *arg
 )
@@ -1285,7 +1285,7 @@ static void _Thread_queue_Priority_inherit_do_surrender_change_2(
   _Scheduler_Node_set_priority(
     SCHEDULER_NODE_OF_WAIT_PRIORITY( priority_aggregation ),
     _Priority_Get_priority( priority_aggregation ),
-    prepend_it
+    priority_flags
   );
 }
 #endif
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 79a154e3d3..94e50c3fd4 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -70,7 +70,7 @@ static void _Thread_Raise_real_priority(
       the_thread,
       &the_thread->Real_priority,
       priority,
-      false,
+      PRIORITY_APPEND_FLAG,
       &queue_context
     );
   }
@@ -576,7 +576,7 @@ Status_Control _Thread_Restart(
     the_thread,
     &the_thread->Real_priority,
     the_thread->Start.initial_priority,
-    false,
+    PRIORITY_APPEND_FLAG,
     &queue_context
   );
   _Thread_Wait_release( the_thread, &queue_context );
diff --git a/testsuites/smptests/smpscheduler03/test.c b/testsuites/smptests/smpscheduler03/test.c
index 3f6b9e3fd8..a11f694934 100644
--- a/testsuites/smptests/smpscheduler03/test.c
+++ b/testsuites/smptests/smpscheduler03/test.c
@@ -33,7 +33,7 @@ static Scheduler_SMP_Node *get_scheduler_node(Thread_Control *thread)
 static void apply_priority(
   Thread_Control *thread,
   Priority_Control new_priority,
-  bool prepend_it,
+  Priority_Flags priority_flags,
   Thread_queue_Context *queue_context
 )
 {
@@ -49,7 +49,7 @@ static void apply_priority(
     thread,
     &thread->Real_priority,
     new_priority,
-    prepend_it,
+    priority_flags,
     queue_context
   );
   _Thread_Wait_release(thread, queue_context);
@@ -58,12 +58,12 @@ static void apply_priority(
 static void change_priority(
   Thread_Control *thread,
   Priority_Control new_priority,
-  bool prepend_it
+  Priority_Flags priority_flags
 )
 {
   Thread_queue_Context queue_context;
 
-  apply_priority(thread, new_priority, prepend_it, &queue_context);
+  apply_priority(thread, new_priority, priority_flags, &queue_context);
   _Thread_Priority_update(&queue_context);
 }
 
@@ -110,7 +110,7 @@ static void test_case_change_priority(
   Scheduler_SMP_Node *executing_node,
   Scheduler_SMP_Node_state start_state,
   Priority_Control prio,
-  bool prepend_it,
+  Priority_Flags priority_flags,
   Scheduler_SMP_Node_state new_state
 )
 {
@@ -131,7 +131,7 @@ static void test_case_change_priority(
   }
   rtems_test_assert(executing_node->state == start_state);
 
-  change_priority(executing, prio, prepend_it);
+  change_priority(executing, prio, priority_flags);
   rtems_test_assert(executing_node->state == new_state);
 
   change_priority(executing, 1, true);
@@ -147,7 +147,10 @@ static const Scheduler_SMP_Node_state states[2] = {
 
 static const Priority_Control priorities[2] = { 2, 5 };
 
-static const bool prepend_it[2] = { true, false };
+static const Priority_Flags priority_flags[2] = {
+  PRIORITY_PREPEND_FLAG,
+  PRIORITY_APPEND_FLAG
+};
 
 static void test_change_priority(void)
 {
@@ -165,13 +168,13 @@ static void test_change_priority(void)
 
   for (i = 0; i < RTEMS_ARRAY_SIZE(states); ++i) {
     for (j = 0; j < RTEMS_ARRAY_SIZE(priorities); ++j) {
-      for (k = 0; k < RTEMS_ARRAY_SIZE(prepend_it); ++k) {
+      for (k = 0; k < RTEMS_ARRAY_SIZE(priority_flags); ++k) {
         test_case_change_priority(
           executing,
           executing_node,
           states[i],
           priorities[j],
-          prepend_it[k],
+          priority_flags[k],
           states[j]
         );
       }
@@ -186,7 +189,7 @@ static void update_priority_op(
   Thread_Control *thread,
   Scheduler_SMP_Node *scheduler_node,
   Priority_Control new_priority,
-  bool prepend_it
+  Priority_Flags priority_flags
 )
 {
   const Scheduler_Control *scheduler;
@@ -194,7 +197,7 @@ static void update_priority_op(
   ISR_lock_Context scheduler_lock_context;
   Thread_queue_Context queue_context;
 
-  apply_priority(thread, new_priority, prepend_it, &queue_context);
+  apply_priority(thread, new_priority, priority_flags, &queue_context);
 
   _Thread_State_acquire( thread, &state_lock_context );
   scheduler = _Thread_Scheduler_get_home( thread );
@@ -216,7 +219,7 @@ static void test_case_update_priority_op(
   Thread_Control *other,
   Scheduler_SMP_Node_state start_state,
   Priority_Control prio,
-  bool prepend_it,
+  Priority_Flags priority_flags,
   Scheduler_SMP_Node_state new_state
 )
 {
@@ -237,7 +240,7 @@ static void test_case_update_priority_op(
   }
   rtems_test_assert(executing_node->state == start_state);
 
-  update_priority_op(executing, executing_node, prio, prepend_it);
+  update_priority_op(executing, executing_node, prio, priority_flags);
   rtems_test_assert(executing_node->state == new_state);
 
   if (start_state != new_state) {
@@ -279,14 +282,14 @@ static void test_update_priority_op(void)
 
   for (i = 0; i < RTEMS_ARRAY_SIZE(states); ++i) {
     for (j = 0; j < RTEMS_ARRAY_SIZE(priorities); ++j) {
-      for (k = 0; k < RTEMS_ARRAY_SIZE(prepend_it); ++k) {
+      for (k = 0; k < RTEMS_ARRAY_SIZE(priority_flags); ++k) {
         test_case_update_priority_op(
           executing,
           executing_node,
           other,
           states[i],
           priorities[j],
-          prepend_it[k],
+          priority_flags[k],
           states[j]
         );
       }
-- 
2.26.2



More information about the devel mailing list