[PATCH 2/2] score: Rename _Scheduler_Update()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Jun 3 14:31:52 UTC 2014


Rename _Scheduler_Update() to _Scheduler_Update_priority().  Add
parameter for the new thread priority to avoid direct usage of
Thread_Control::current_priority in the scheduler operation.
---
 cpukit/score/include/rtems/score/scheduler.h       |   14 ++++++++++----
 cpukit/score/include/rtems/score/schedulercbs.h    |    2 +-
 cpukit/score/include/rtems/score/scheduleredf.h    |    7 ++++---
 cpukit/score/include/rtems/score/schedulerimpl.h   |   20 +++++++++++++++-----
 .../score/include/rtems/score/schedulerpriority.h  |   15 ++++++---------
 .../rtems/score/schedulerpriorityaffinitysmp.h     |    2 +-
 .../include/rtems/score/schedulerprioritysmp.h     |    7 ++++---
 cpukit/score/include/rtems/score/schedulersimple.h |    2 +-
 .../score/include/rtems/score/schedulersimplesmp.h |    2 +-
 cpukit/score/src/schedulerdefaultupdate.c          |   10 ++++++----
 cpukit/score/src/scheduleredfupdate.c              |    6 ++++--
 cpukit/score/src/schedulerprioritysmp.c            |    7 ++++---
 cpukit/score/src/schedulerpriorityupdate.c         |    7 ++++---
 cpukit/score/src/threadchangepriority.c            |    2 +-
 cpukit/score/src/threadsetpriority.c               |    6 +++++-
 15 files changed, 67 insertions(+), 42 deletions(-)

diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index 7ca2133..542e4ae 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -77,8 +77,12 @@ typedef struct {
   /** @see _Scheduler_Node_destroy() */
   void ( *node_destroy )( const Scheduler_Control *, Thread_Control * );
 
-  /** @see _Scheduler_Update() */
-  void ( *update )( const Scheduler_Control *, Thread_Control * );
+  /** @see _Scheduler_Update_priority() */
+  void ( *update_priority )(
+    const Scheduler_Control *,
+    Thread_Control *,
+    Priority_Control
+  );
 
   /** @see _Scheduler_Priority_compare() */
   int ( *priority_compare )(
@@ -277,10 +281,12 @@ void _Scheduler_default_Node_destroy(
  *
  * @param[in] scheduler Unused.
  * @param[in] the_thread Unused.
+ * @param[in] new_priority Unused.
  */
-void _Scheduler_default_Update(
+void _Scheduler_default_Update_priority(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Thread_Control          *the_thread,
+  Priority_Control         new_priority
 );
 
 /**
diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h
index 23e528d..473d6fe 100644
--- a/cpukit/score/include/rtems/score/schedulercbs.h
+++ b/cpukit/score/include/rtems/score/schedulercbs.h
@@ -55,7 +55,7 @@ extern "C" {
     _Scheduler_EDF_Change_priority,  /* change priority entry point */ \
     _Scheduler_CBS_Node_initialize,  /* node initialize entry point */ \
     _Scheduler_default_Node_destroy, /* node destroy entry point */ \
-    _Scheduler_EDF_Update,           /* update entry point */ \
+    _Scheduler_EDF_Update_priority,  /* update priority entry point */ \
     _Scheduler_EDF_Priority_compare, /* compares two priorities */ \
     _Scheduler_CBS_Release_job,      /* new period of task */ \
     _Scheduler_default_Tick,         /* tick entry point */ \
diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h
index a7ed88d..7a20b5b 100644
--- a/cpukit/score/include/rtems/score/scheduleredf.h
+++ b/cpukit/score/include/rtems/score/scheduleredf.h
@@ -48,7 +48,7 @@ extern "C" {
     _Scheduler_EDF_Change_priority,  /* change priority entry point */ \
     _Scheduler_EDF_Node_initialize,  /* node initialize entry point */ \
     _Scheduler_default_Node_destroy, /* node destroy entry point */ \
-    _Scheduler_EDF_Update,           /* update entry point */ \
+    _Scheduler_EDF_Update_priority,  /* update priority entry point */ \
     _Scheduler_EDF_Priority_compare, /* compares two priorities */ \
     _Scheduler_EDF_Release_job,      /* new period of task */ \
     _Scheduler_default_Tick,         /* tick entry point */ \
@@ -161,9 +161,10 @@ void _Scheduler_EDF_Node_initialize(
  *  @param[in] the_thread will have its scheduler specific information
  *             structure updated.
  */
-void _Scheduler_EDF_Update(
+void _Scheduler_EDF_Update_priority(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Thread_Control          *the_thread,
+  Priority_Control         new_priority
 );
 
 /**
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 5e7c928..1216f6c 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -209,16 +209,22 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy(
 }
 
 /**
- * @brief Scheduler update.
+ * @brief Updates the scheduler about a priority change of a not ready thread.
  *
- * This routine updates @a the_thread->scheduler
+ * @param[in] the_thread The thread.
+ * @param[in] new_priority The new priority of the thread.
  */
-RTEMS_INLINE_ROUTINE void _Scheduler_Update(
+RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority(
   const Scheduler_Control *scheduler,
   Thread_Control          *the_thread
+  Priority_Control         new_priority
 )
 {
-  ( *scheduler->Operations.update )( scheduler, the_thread );
+  ( *scheduler->Operations.update_priority )(
+    scheduler,
+    the_thread,
+    new_priority
+  );
 }
 
 /**
@@ -367,7 +373,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Set(
     _Scheduler_Node_destroy( current_scheduler, the_thread );
     the_thread->scheduler = scheduler;
     _Scheduler_Node_initialize( scheduler, the_thread );
-    _Scheduler_Update( scheduler, the_thread );
+    _Scheduler_Update_priority(
+      scheduler,
+      the_thread,
+      the_thread->current_priority
+    );
     _Thread_Clear_state( the_thread, STATES_MIGRATING );
   }
 #else
diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h
index 3f18f54..2e4f3ab 100644
--- a/cpukit/score/include/rtems/score/schedulerpriority.h
+++ b/cpukit/score/include/rtems/score/schedulerpriority.h
@@ -55,7 +55,7 @@ extern "C" {
     _Scheduler_priority_Change_priority,  /* change priority entry point */ \
     _Scheduler_default_Node_initialize,   /* node initialize entry point */ \
     _Scheduler_default_Node_destroy,      /* node destroy entry point */ \
-    _Scheduler_priority_Update,           /* update entry point */ \
+    _Scheduler_priority_Update_priority,  /* update priority entry point */ \
     _Scheduler_priority_Priority_compare, /* compares two priorities */ \
     _Scheduler_default_Release_job,       /* new period of task */ \
     _Scheduler_default_Tick,              /* tick entry point */ \
@@ -139,16 +139,13 @@ void _Scheduler_priority_Schedule(
 );
 
 /**
- *  @brief Update the scheduler priority.
- *  This routine updates @a the_thread->scheduler based on @a the_scheduler
- *  structures and thread state.
- *
- *  @param[in] the_thread will have its scheduler specific information
- *             structure updated.
+ *  @brief Updates the scheduler node to reflect the new priority of the
+ *  thread.
  */
-void _Scheduler_priority_Update(
+void _Scheduler_priority_Update_priority(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Thread_Control          *the_thread,
+  Priority_Control         new_priority
 );
 
 /**
diff --git a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
index ab35704..0ba8191 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
@@ -57,7 +57,7 @@ extern "C" {
     _Scheduler_priority_SMP_Change_priority, \
     _Scheduler_priority_affinity_SMP_Node_initialize, \
     _Scheduler_default_Node_destroy, \
-    _Scheduler_priority_SMP_Update, \
+    _Scheduler_priority_SMP_Update_priority, \
     _Scheduler_priority_Priority_compare, \
     _Scheduler_default_Release_job, \
     _Scheduler_default_Tick, \
diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
index c17fcf4..cbb8a58 100644
--- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h
+++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
@@ -86,7 +86,7 @@ typedef struct {
     _Scheduler_priority_SMP_Change_priority, \
     _Scheduler_priority_SMP_Node_initialize, \
     _Scheduler_default_Node_destroy, \
-    _Scheduler_priority_SMP_Update, \
+    _Scheduler_priority_SMP_Update_priority, \
     _Scheduler_priority_Priority_compare, \
     _Scheduler_default_Release_job, \
     _Scheduler_default_Tick, \
@@ -119,9 +119,10 @@ void _Scheduler_priority_SMP_Change_priority(
   bool                     prepend_it
 );
 
-void _Scheduler_priority_SMP_Update(
+void _Scheduler_priority_SMP_Update_priority(
   const Scheduler_Control *scheduler,
-  Thread_Control *thread
+  Thread_Control *thread,
+  Priority_Control new_priority
 );
 
 void _Scheduler_priority_SMP_Yield(
diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h
index 9fc2d31..68ed527 100644
--- a/cpukit/score/include/rtems/score/schedulersimple.h
+++ b/cpukit/score/include/rtems/score/schedulersimple.h
@@ -45,7 +45,7 @@ extern "C" {
     _Scheduler_simple_Change_priority,    /* change priority entry point */ \
     _Scheduler_default_Node_initialize,   /* node initialize entry point */ \
     _Scheduler_default_Node_destroy,      /* node destroy entry point */ \
-    _Scheduler_default_Update,            /* update entry point */ \
+    _Scheduler_default_Update_priority,   /* update priority entry point */ \
     _Scheduler_priority_Priority_compare, /* compares two priorities */ \
     _Scheduler_default_Release_job,       /* new period of task */ \
     _Scheduler_default_Tick,              /* tick entry point */ \
diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h
index 6ab1dd2..c0195e0 100644
--- a/cpukit/score/include/rtems/score/schedulersimplesmp.h
+++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h
@@ -67,7 +67,7 @@ typedef struct {
     _Scheduler_simple_SMP_Change_priority, \
     _Scheduler_simple_SMP_Node_initialize, \
     _Scheduler_default_Node_destroy, \
-    _Scheduler_default_Update, \
+    _Scheduler_default_Update_priority, \
     _Scheduler_priority_Priority_compare, \
     _Scheduler_default_Release_job, \
     _Scheduler_default_Tick, \
diff --git a/cpukit/score/src/schedulerdefaultupdate.c b/cpukit/score/src/schedulerdefaultupdate.c
index 28d7e1d..fcdc838 100644
--- a/cpukit/score/src/schedulerdefaultupdate.c
+++ b/cpukit/score/src/schedulerdefaultupdate.c
@@ -21,11 +21,13 @@
 
 #include <rtems/score/scheduler.h>
 
-void _Scheduler_default_Update(
+void _Scheduler_default_Update_priority(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Thread_Control          *the_thread,
+  Priority_Control         new_priority
 )
 {
-  ( void ) scheduler;
-  ( void ) the_thread;
+  (void) scheduler;
+  (void) the_thread;
+  (void) new_priority;
 }
diff --git a/cpukit/score/src/scheduleredfupdate.c b/cpukit/score/src/scheduleredfupdate.c
index 99a3e0e..47e3a70 100644
--- a/cpukit/score/src/scheduleredfupdate.c
+++ b/cpukit/score/src/scheduleredfupdate.c
@@ -20,14 +20,16 @@
 
 #include <rtems/score/scheduleredfimpl.h>
 
-void _Scheduler_EDF_Update(
+void _Scheduler_EDF_Update_priority(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Thread_Control          *the_thread,
+  Priority_Control         new_priority
 )
 {
   Scheduler_EDF_Node *node = _Scheduler_EDF_Node_get( the_thread );
 
   (void) scheduler;
+  (void) new_priority;
 
   if (node->queue_state == SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN) {
     /* Shifts the priority to the region of background tasks. */
diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
index e0ed75c..7915ce6 100644
--- a/cpukit/score/src/schedulerprioritysmp.c
+++ b/cpukit/score/src/schedulerprioritysmp.c
@@ -93,15 +93,16 @@ static void _Scheduler_priority_SMP_Do_update(
   );
 }
 
-void _Scheduler_priority_SMP_Update(
+void _Scheduler_priority_SMP_Update_priority(
   const Scheduler_Control *scheduler,
-  Thread_Control *thread
+  Thread_Control *thread,
+  Priority_Control new_priority
 )
 {
   Scheduler_Context *context = _Scheduler_Get_context( scheduler );
   Scheduler_Node *node = _Scheduler_Node_get( thread );
 
-  _Scheduler_priority_SMP_Do_update( context, node, thread->current_priority );
+  _Scheduler_priority_SMP_Do_update( context, node, new_priority );
 }
 
 static Thread_Control *_Scheduler_priority_SMP_Get_highest_ready(
diff --git a/cpukit/score/src/schedulerpriorityupdate.c b/cpukit/score/src/schedulerpriorityupdate.c
index e58a609..3f05439 100644
--- a/cpukit/score/src/schedulerpriorityupdate.c
+++ b/cpukit/score/src/schedulerpriorityupdate.c
@@ -20,9 +20,10 @@
 
 #include <rtems/score/schedulerpriorityimpl.h>
 
-void _Scheduler_priority_Update(
+void _Scheduler_priority_Update_priority(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Thread_Control          *the_thread,
+  Priority_Control         new_priority
 )
 {
   Scheduler_priority_Context *context =
@@ -31,7 +32,7 @@ void _Scheduler_priority_Update(
 
   _Scheduler_priority_Ready_queue_update(
     &node->Ready_queue,
-    the_thread->current_priority,
+    new_priority,
     &context->Bit_map,
     &context->Ready[ 0 ]
   );
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index 8059ab1..8de6325 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -106,7 +106,7 @@ void _Thread_Change_priority(
       scheduler = _Scheduler_Get( the_thread );
       _Scheduler_Schedule( scheduler, the_thread );
     } else {
-      _Scheduler_Update( scheduler, the_thread );
+      _Scheduler_Update_priority( the_thread, new_priority );
     }
     _ISR_Enable( level );
 
diff --git a/cpukit/score/src/threadsetpriority.c b/cpukit/score/src/threadsetpriority.c
index e128648..455cf20 100644
--- a/cpukit/score/src/threadsetpriority.c
+++ b/cpukit/score/src/threadsetpriority.c
@@ -28,5 +28,9 @@ void _Thread_Set_priority(
 {
   the_thread->current_priority = new_priority;
 
-  _Scheduler_Update( _Scheduler_Get( the_thread ), the_thread );
+  _Scheduler_Update_priority(
+    _Scheduler_Get( the_thread),
+    the_thread,
+    new_priority
+  );
 }
-- 
1.7.7




More information about the devel mailing list