[rtems commit] score: Add _Scheduler_Change_priority_if_higher()

Sebastian Huber sebh at rtems.org
Mon Mar 31 08:09:15 UTC 2014


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Mar 28 09:24:28 2014 +0100

score: Add _Scheduler_Change_priority_if_higher()

Add _Scheduler_Set_priority_if_higher().

---

 cpukit/score/include/rtems/score/schedulerimpl.h |   33 ++++++++++++++++++++++
 cpukit/score/src/coremutexseize.c                |   14 +++------
 2 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index e70e466..a031715 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -304,6 +304,39 @@ RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Highest_priority_of_two(
   return _Scheduler_Is_priority_higher_than( p1, p2 ) ? p1 : p2;
 }
 
+/**
+ * @brief Sets the thread priority to @a priority if it is higher than the
+ * current priority of the thread in the intuitive sense of priority.
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Set_priority_if_higher(
+  Thread_Control   *the_thread,
+  Priority_Control  priority
+)
+{
+  Priority_Control current = the_thread->current_priority;
+
+  if ( _Scheduler_Is_priority_higher_than( priority, current ) ) {
+    _Thread_Set_priority( the_thread, priority );
+  }
+}
+
+/**
+ * @brief Changes the thread priority to @a priority if it is higher than the
+ * current priority of the thread in the intuitive sense of priority.
+ */
+RTEMS_INLINE_ROUTINE void _Scheduler_Change_priority_if_higher(
+  Thread_Control   *the_thread,
+  Priority_Control  priority,
+  bool              prepend_it
+)
+{
+  Priority_Control current = the_thread->current_priority;
+
+  if ( _Scheduler_Is_priority_higher_than( priority, current ) ) {
+    _Thread_Change_priority( the_thread, priority, prepend_it );
+  }
+}
+
 /** @} */
 
 #ifdef __cplusplus
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 5997293..d6e817c 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -53,15 +53,11 @@ void _CORE_mutex_Seize_interrupt_blocking(
 {
 
   if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) {
-    if ( _Scheduler_Is_priority_higher_than(
-         executing->current_priority,
-         the_mutex->holder->current_priority)) {
-      _Thread_Change_priority(
-        the_mutex->holder,
-        executing->current_priority,
-        false
-      );
-    }
+    _Scheduler_Change_priority_if_higher(
+      the_mutex->holder,
+      executing->current_priority,
+      false
+    );
   }
 
   the_mutex->blocked_count++;




More information about the vc mailing list