[PATCH 01/12] score: Add _Scheduler_priority_Get_scheduler_info

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Aug 13 13:42:46 UTC 2013


Add and use _Scheduler_priority_Get_scheduler_info().
---
 .../include/rtems/score/schedulerpriorityimpl.h    |   61 +++++++++-----------
 cpukit/score/src/schedulerpriorityallocate.c       |   14 ++---
 cpukit/score/src/schedulerpriorityupdate.c         |   10 ++--
 cpukit/score/src/schedulerpriorityyield.c          |   15 ++---
 4 files changed, 44 insertions(+), 56 deletions(-)

diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
index 73c635d..7400e58 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
@@ -57,6 +57,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(void)
     _Chain_Initialize_empty( &ready_queues[index] );
 }
 
+RTEMS_INLINE_ROUTINE Scheduler_priority_Per_thread *
+_Scheduler_priority_Get_scheduler_info( Thread_Control *thread )
+{
+  return ( Scheduler_priority_Per_thread * ) thread->scheduler_info;
+}
+
 /**
  * @brief Put a thread to the ready queue.
  *
@@ -68,15 +74,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(
   Thread_Control                  *the_thread
 )
 {
-  Scheduler_priority_Per_thread *sched_info;
-  Chain_Control                 *ready;
+  Scheduler_priority_Per_thread *sched_info_of_thread =
+    _Scheduler_priority_Get_scheduler_info( the_thread );
+  Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
 
-  sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
-  ready      = sched_info->ready_chain;
-
-  _Priority_bit_map_Add( &sched_info->Priority_map );
-
-  _Chain_Append_unprotected( ready, &the_thread->Object.Node );
+  _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node );
+  _Priority_bit_map_Add( &sched_info_of_thread->Priority_map );
 }
 
 /**
@@ -92,16 +95,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(
   Thread_Control                   *the_thread
 )
 {
-  Scheduler_priority_Per_thread *sched_info;
-
-  sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
+  Scheduler_priority_Per_thread *sched_info_of_thread =
+    _Scheduler_priority_Get_scheduler_info( the_thread );
+  Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
 
-  _Priority_bit_map_Add( &sched_info->Priority_map );
-
-  _Chain_Prepend_unprotected(
-    sched_info->ready_chain,
-    &the_thread->Object.Node
-  );
+  _Chain_Prepend_unprotected( ready_chain, &the_thread->Object.Node );
+  _Priority_bit_map_Add( &sched_info_of_thread->Priority_map );
 }
 
 /**
@@ -116,15 +115,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
   Thread_Control        *the_thread
 )
 {
-  Scheduler_priority_Per_thread *sched_info;
-  Chain_Control                 *ready;
-
-  sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
-  ready      = sched_info->ready_chain;
+  Scheduler_priority_Per_thread *sched_info_of_thread =
+    _Scheduler_priority_Get_scheduler_info( the_thread );
+  Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
 
-  if ( _Chain_Has_only_one_node( ready ) ) {
-    _Chain_Initialize_empty( ready );
-    _Priority_bit_map_Remove( &sched_info->Priority_map );
+  if ( _Chain_Has_only_one_node( ready_chain ) ) {
+    _Chain_Initialize_empty( ready_chain );
+    _Priority_bit_map_Remove( &sched_info_of_thread->Priority_map );
   } else {
     _Chain_Extract_unprotected( &the_thread->Object.Node );
   }
@@ -163,17 +160,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_requeue(
   Thread_Control            *the_thread
 )
 {
-  Scheduler_priority_Per_thread *sched_info;
+  Scheduler_priority_Per_thread *sched_info_of_thread =
+    _Scheduler_priority_Get_scheduler_info( the_thread );
+  Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
 
-  sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
-
-  if ( !_Chain_Has_only_one_node( sched_info->ready_chain ) ) {
+  if ( !_Chain_Has_only_one_node( ready_chain ) ) {
     _Chain_Extract_unprotected( &the_thread->Object.Node );
-
-    _Chain_Append_unprotected(
-      sched_info->ready_chain,
-      &the_thread->Object.Node
-    );
+    _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node );
   }
 }
 
diff --git a/cpukit/score/src/schedulerpriorityallocate.c b/cpukit/score/src/schedulerpriorityallocate.c
index 8c2291f..ec0f210 100644
--- a/cpukit/score/src/schedulerpriorityallocate.c
+++ b/cpukit/score/src/schedulerpriorityallocate.c
@@ -18,21 +18,17 @@
 #include "config.h"
 #endif
 
-#include <rtems/system.h>
-#include <rtems/config.h>
-#include <rtems/score/scheduler.h>
 #include <rtems/score/schedulerpriority.h>
 #include <rtems/score/wkspace.h>
 
-void* _Scheduler_priority_Allocate (
+void *_Scheduler_priority_Allocate (
   Thread_Control        *the_thread
 )
 {
-  void *sched;
+  Scheduler_priority_Per_thread *sched_info_of_thread =
+    _Workspace_Allocate( sizeof( *sched_info_of_thread ) );
 
-  sched = _Workspace_Allocate( sizeof(Scheduler_priority_Per_thread) );
+  the_thread->scheduler_info = sched_info_of_thread;
 
-  the_thread->scheduler_info = (Scheduler_priority_Per_thread*) sched;
-
-  return sched;
+  return sched_info_of_thread;
 }
diff --git a/cpukit/score/src/schedulerpriorityupdate.c b/cpukit/score/src/schedulerpriorityupdate.c
index aa54d31..1935e13 100644
--- a/cpukit/score/src/schedulerpriorityupdate.c
+++ b/cpukit/score/src/schedulerpriorityupdate.c
@@ -25,16 +25,16 @@ void _Scheduler_priority_Update(
   Thread_Control    *the_thread
 )
 {
-  Scheduler_priority_Per_thread *sched_info;
+  Scheduler_priority_Per_thread *sched_info_of_thread =
+    _Scheduler_priority_Get_scheduler_info( the_thread );
   Chain_Control                 *rq;
 
-  sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
-  rq         = (Chain_Control *) _Scheduler.information;
+  rq                   = (Chain_Control *) _Scheduler.information;
 
-  sched_info->ready_chain = &rq[ the_thread->current_priority ];
+  sched_info_of_thread->ready_chain = &rq[ the_thread->current_priority ];
 
   _Priority_bit_map_Initialize_information(
-    &sched_info->Priority_map,
+    &sched_info_of_thread->Priority_map,
     the_thread->current_priority
   );
 }
diff --git a/cpukit/score/src/schedulerpriorityyield.c b/cpukit/score/src/schedulerpriorityyield.c
index fa9a1f1..9fdf719 100644
--- a/cpukit/score/src/schedulerpriorityyield.c
+++ b/cpukit/score/src/schedulerpriorityyield.c
@@ -24,21 +24,20 @@
 
 void _Scheduler_priority_Yield( Thread_Control *thread )
 {
-  Scheduler_priority_Per_thread *sched_info;
-  ISR_Level                      level;
-  Chain_Control                 *ready;
+  Scheduler_priority_Per_thread *sched_info_of_thread =
+    _Scheduler_priority_Get_scheduler_info( thread );
+  Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
+  ISR_Level level;
 
-  sched_info = (Scheduler_priority_Per_thread *) thread->scheduler_info;
-  ready      = sched_info->ready_chain;
   _ISR_Disable( level );
-    if ( !_Chain_Has_only_one_node( ready ) ) {
+    if ( !_Chain_Has_only_one_node( ready_chain ) ) {
       _Chain_Extract_unprotected( &thread->Object.Node );
-      _Chain_Append_unprotected( ready, &thread->Object.Node );
+      _Chain_Append_unprotected( ready_chain, &thread->Object.Node );
 
       _ISR_Flash( level );
 
       if ( _Thread_Is_heir( thread ) )
-        _Thread_Heir = (Thread_Control *) _Chain_First( ready );
+        _Thread_Heir = (Thread_Control *) _Chain_First( ready_chain );
       _Thread_Dispatch_necessary = true;
     }
     else if ( !_Thread_Is_heir( thread ) )
-- 
1.7.7




More information about the devel mailing list