[PATCH 3/6] score: Use chain nodes for ready queue support

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 13 14:37:20 UTC 2014


This reduces the API to the minimum data structures to maximize the
re-usability.
---
 .../include/rtems/score/schedulerpriorityimpl.h    |   49 ++++++++++----------
 .../include/rtems/score/schedulerprioritysmpimpl.h |   12 ++--
 cpukit/score/src/schedulerprioritychangepriority.c |    6 +-
 cpukit/score/src/schedulerprioritysmp.c            |    2 +-
 cpukit/score/src/schedulerpriorityunblock.c        |    2 +-
 5 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
index 3980d10..063d436 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
@@ -65,56 +65,56 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(
 }
 
 /**
- * @brief Enqueues a thread on the specified ready queue.
+ * @brief Enqueues a node on the specified ready queue.
  *
- * The thread is placed as the last element of its priority group.
+ * The node is placed as the last element of its priority group.
  *
- * @param[in] the_thread The thread to enqueue.
+ * @param[in] node The node to enqueue.
  * @param[in] ready_queue The ready queue.
  * @param[in] bit_map The priority bit map of the scheduler instance.
  */
 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(
-  Thread_Control                 *the_thread,
+  Chain_Node                     *node,
   Scheduler_priority_Ready_queue *ready_queue,
   Priority_bit_map_Control       *bit_map
 )
 {
   Chain_Control *ready_chain = ready_queue->ready_chain;
 
-  _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node );
+  _Chain_Append_unprotected( ready_chain, node );
   _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
 }
 
 /**
- * @brief Enqueues a thread on the specified ready queue as first.
+ * @brief Enqueues a node on the specified ready queue as first.
  *
- * The thread is placed as the first element of its priority group.
+ * The node is placed as the first element of its priority group.
  *
- * @param[in] the_thread The thread to enqueue as first.
+ * @param[in] node The node to enqueue as first.
  * @param[in] ready_queue The ready queue.
  * @param[in] bit_map The priority bit map of the scheduler instance.
  */
 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(
-  Thread_Control                 *the_thread,
+  Chain_Node                     *node,
   Scheduler_priority_Ready_queue *ready_queue,
   Priority_bit_map_Control       *bit_map
 )
 {
   Chain_Control *ready_chain = ready_queue->ready_chain;
 
-  _Chain_Prepend_unprotected( ready_chain, &the_thread->Object.Node );
+  _Chain_Prepend_unprotected( ready_chain, node );
   _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
 }
 
 /**
- * @brief Extracts a thread from the specified ready queue.
+ * @brief Extracts a node from the specified ready queue.
  *
- * @param[in] the_thread The thread to extract.
+ * @param[in] node The node to extract.
  * @param[in] ready_queue The ready queue.
  * @param[in] bit_map The priority bit map of the scheduler instance.
  */
 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
-  Thread_Control                 *the_thread,
+  Chain_Node                     *node,
   Scheduler_priority_Ready_queue *ready_queue,
   Priority_bit_map_Control       *bit_map
 )
@@ -125,7 +125,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
     _Chain_Initialize_empty( ready_chain );
     _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map );
   } else {
-    _Chain_Extract_unprotected( &the_thread->Object.Node );
+    _Chain_Extract_unprotected( node );
   }
 }
 
@@ -139,30 +139,30 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body(
   Scheduler_priority_Node *node = _Scheduler_priority_Node_get( the_thread );
 
   _Scheduler_priority_Ready_queue_extract(
-    the_thread,
+    &the_thread->Object.Node,
     &node->Ready_queue,
     &context->Bit_map
   );
 }
 
 /**
- * @brief Return a pointer to the first thread.
+ * @brief Return a pointer to the first node.
  *
- * This routines returns a pointer to the first thread on @a ready_queues.
+ * This routines returns a pointer to the first node on @a ready_queues.
  *
  * @param[in] bit_map The priority bit map of the scheduler instance.
  * @param[in] ready_queues The ready queues of the scheduler instance.
  *
- * @return This method returns the first thread or NULL
+ * @return This method returns the first node.
  */
-RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_priority_Ready_queue_first(
+RTEMS_INLINE_ROUTINE Chain_Node *_Scheduler_priority_Ready_queue_first(
   Priority_bit_map_Control *bit_map,
   Chain_Control            *ready_queues
 )
 {
   Priority_Control index = _Priority_bit_map_Get_highest( bit_map );
 
-  return (Thread_Control *) _Chain_First( &ready_queues[ index ] );
+  return _Chain_First( &ready_queues[ index ] );
 }
 
 /**
@@ -179,10 +179,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(
 {
   Scheduler_priority_Context *context =
     _Scheduler_priority_Get_context( scheduler );
-  Thread_Control *heir = _Scheduler_priority_Ready_queue_first(
-    &context->Bit_map,
-    &context->Ready[ 0 ]
-  );
+  Thread_Control *heir = (Thread_Control *)
+    _Scheduler_priority_Ready_queue_first(
+      &context->Bit_map,
+      &context->Ready[ 0 ]
+    );
 
   ( void ) the_thread;
 
diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h b/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h
index a819621..d3e2106 100644
--- a/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h
@@ -69,7 +69,7 @@ static inline void _Scheduler_priority_SMP_Move_from_scheduled_to_ready(
 
   _Chain_Extract_unprotected( &scheduled_to_ready->Object.Node );
   _Scheduler_priority_Ready_queue_enqueue_first(
-    scheduled_to_ready,
+    &scheduled_to_ready->Object.Node,
     &node->Ready_queue,
     &self->Bit_map
   );
@@ -86,13 +86,13 @@ static inline void _Scheduler_priority_SMP_Move_from_ready_to_scheduled(
     _Scheduler_priority_SMP_Node_get( ready_to_scheduled );
 
   _Scheduler_priority_Ready_queue_extract(
-    ready_to_scheduled,
+    &ready_to_scheduled->Object.Node,
     &node->Ready_queue,
     &self->Bit_map
   );
   _Scheduler_simple_Insert_priority_fifo(
     &self->Base.Scheduled,
-    ready_to_scheduled
+    &ready_to_scheduled->Object.Node
   );
 }
 
@@ -107,7 +107,7 @@ static inline void _Scheduler_priority_SMP_Insert_ready_lifo(
     _Scheduler_priority_SMP_Node_get( thread );
 
   _Scheduler_priority_Ready_queue_enqueue(
-    thread,
+    &thread->Object.Node,
     &node->Ready_queue,
     &self->Bit_map
   );
@@ -124,7 +124,7 @@ static inline void _Scheduler_priority_SMP_Insert_ready_fifo(
     _Scheduler_priority_SMP_Node_get( thread );
 
   _Scheduler_priority_Ready_queue_enqueue_first(
-    thread,
+    &thread->Object.Node,
     &node->Ready_queue,
     &self->Bit_map
   );
@@ -141,7 +141,7 @@ static inline void _Scheduler_priority_SMP_Extract_from_ready(
     _Scheduler_priority_SMP_Node_get( thread );
 
   _Scheduler_priority_Ready_queue_extract(
-    thread,
+    &thread->Object.Node,
     &node->Ready_queue,
     &self->Bit_map
   );
diff --git a/cpukit/score/src/schedulerprioritychangepriority.c b/cpukit/score/src/schedulerprioritychangepriority.c
index 448c603..91b9fa7 100644
--- a/cpukit/score/src/schedulerprioritychangepriority.c
+++ b/cpukit/score/src/schedulerprioritychangepriority.c
@@ -33,7 +33,7 @@ void _Scheduler_priority_Change_priority(
   Scheduler_priority_Node *node = _Scheduler_priority_Node_get( the_thread );
 
   _Scheduler_priority_Ready_queue_extract(
-    the_thread,
+    &the_thread->Object.Node,
     &node->Ready_queue,
     &context->Bit_map
   );
@@ -47,13 +47,13 @@ void _Scheduler_priority_Change_priority(
 
   if ( prepend_it ) {
     _Scheduler_priority_Ready_queue_enqueue_first(
-      the_thread,
+      &the_thread->Object.Node,
       &node->Ready_queue,
       &context->Bit_map
     );
   } else {
     _Scheduler_priority_Ready_queue_enqueue(
-      the_thread,
+      &the_thread->Object.Node,
       &node->Ready_queue,
       &context->Bit_map
     );
diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
index bcbd26d..b6b5ff4 100644
--- a/cpukit/score/src/schedulerprioritysmp.c
+++ b/cpukit/score/src/schedulerprioritysmp.c
@@ -75,7 +75,7 @@ static Thread_Control *_Scheduler_priority_SMP_Get_highest_ready(
 
   (void) thread;
 
-  return _Scheduler_priority_Ready_queue_first(
+  return (Thread_Control *) _Scheduler_priority_Ready_queue_first(
     &self->Bit_map,
     &self->Ready[ 0 ]
   );
diff --git a/cpukit/score/src/schedulerpriorityunblock.c b/cpukit/score/src/schedulerpriorityunblock.c
index e83bff1..ef46df8 100644
--- a/cpukit/score/src/schedulerpriorityunblock.c
+++ b/cpukit/score/src/schedulerpriorityunblock.c
@@ -32,7 +32,7 @@ void _Scheduler_priority_Unblock (
   Scheduler_priority_Node *node = _Scheduler_priority_Node_get( the_thread );
 
   _Scheduler_priority_Ready_queue_enqueue(
-    the_thread,
+    &the_thread->Object.Node,
     &node->Ready_queue,
     &context->Bit_map
   );
-- 
1.7.7




More information about the devel mailing list