[PATCH] score: Fix _Thread_Change_priority()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Mar 17 16:22:33 UTC 2015


Atomically update the current priority of a thread and all related data
structures.

Close #2310.
---
 cpukit/score/src/threadchangepriority.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index d61dfb8..34a5a14 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -29,15 +29,15 @@ void _Thread_Change_priority(
   bool              prepend_it
 )
 {
+  ISR_Level level;
+
+  _ISR_Disable( level );
+
   /*
    *  Do not bother recomputing all the priority related information if
    *  we are not REALLY changing priority.
    */
   if ( the_thread->current_priority != new_priority ) {
-    ISR_Level level;
-
-    _ISR_Disable( level );
-
     the_thread->current_priority = new_priority;
 
     if ( _States_Is_ready( the_thread->current_state ) ) {
@@ -50,8 +50,8 @@ void _Thread_Change_priority(
       _Scheduler_Update_priority( the_thread, new_priority );
     }
 
-    _ISR_Enable( level );
-
     _Thread_queue_Requeue( the_thread->Wait.queue, the_thread );
   }
+
+  _ISR_Enable( level );
 }
-- 
2.1.4



More information about the devel mailing list