summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadsetpriority.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-05 13:05:54 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-19 12:00:47 +0200
commit900d337f960cb7cc53f5c93c29a503e5ced2c31f (patch)
tree1d1f49724e5cfcef1974d5dc4251486b0fddd2ef /cpukit/score/src/threadsetpriority.c
parentscore: Fine grained locking for mutexes (diff)
downloadrtems-900d337f960cb7cc53f5c93c29a503e5ced2c31f.tar.bz2
score: Rework _Thread_Change_priority()
Move the writes to Thread_Control::current_priority and Thread_Control::real_priority into _Thread_Change_priority() under the protection of the thread lock. Add a filter function to _Thread_Change_priority() to enable specialized variants. Avoid race conditions during a thread priority restore with the new Thread_Control::priority_restore_hint for an important average case optimizations used by priority inheritance mutexes. Update #2273.
Diffstat (limited to 'cpukit/score/src/threadsetpriority.c')
-rw-r--r--cpukit/score/src/threadsetpriority.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/cpukit/score/src/threadsetpriority.c b/cpukit/score/src/threadsetpriority.c
index e1ff118c7e..f6a061a281 100644
--- a/cpukit/score/src/threadsetpriority.c
+++ b/cpukit/score/src/threadsetpriority.c
@@ -19,14 +19,41 @@
#endif
#include <rtems/score/threadimpl.h>
-#include <rtems/score/schedulerimpl.h>
-void _Thread_Set_priority(
+static bool _Thread_Set_priority_filter(
Thread_Control *the_thread,
- Priority_Control new_priority
+ Priority_Control *new_priority_ptr,
+ void *arg
)
{
- the_thread->current_priority = new_priority;
+ Priority_Control current_priority;
+ Priority_Control new_priority;
+ Priority_Control *old_priority_ptr;
+
+ current_priority = the_thread->current_priority;
+ new_priority = *new_priority_ptr;
+
+ old_priority_ptr = arg;
+ *old_priority_ptr = current_priority;
+
+ the_thread->real_priority = new_priority;
+
+ return _Thread_Priority_less_than( current_priority, new_priority )
+ || !_Thread_Owns_resources( the_thread );
+}
- _Scheduler_Update_priority( the_thread, new_priority );
+void _Thread_Set_priority(
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ Priority_Control *old_priority,
+ bool prepend_it
+)
+{
+ _Thread_Change_priority(
+ the_thread,
+ new_priority,
+ old_priority,
+ _Thread_Set_priority_filter,
+ prepend_it
+ );
}