summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
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/rtems
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/rtems')
-rw-r--r--cpukit/rtems/src/tasksetpriority.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/cpukit/rtems/src/tasksetpriority.c b/cpukit/rtems/src/tasksetpriority.c
index 4e4835675d..582c67f9f2 100644
--- a/cpukit/rtems/src/tasksetpriority.c
+++ b/cpukit/rtems/src/tasksetpriority.c
@@ -41,16 +41,18 @@ rtems_status_code rtems_task_set_priority(
switch ( location ) {
case OBJECTS_LOCAL:
- *old_priority = _RTEMS_tasks_Priority_from_Core(
- the_thread->current_priority
- );
if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
- the_thread->real_priority = _RTEMS_tasks_Priority_to_Core(
- new_priority
- );
- if ( !_Thread_Owns_resources( the_thread ) ||
- the_thread->current_priority > new_priority )
- _Thread_Change_priority( the_thread, new_priority, false );
+ _Thread_Set_priority(
+ the_thread,
+ _RTEMS_tasks_Priority_to_Core( new_priority ),
+ old_priority,
+ false
+ );
+ *old_priority = _RTEMS_tasks_Priority_from_Core( *old_priority );
+ } else {
+ *old_priority = _RTEMS_tasks_Priority_from_Core(
+ the_thread->current_priority
+ );
}
_Objects_Put( &the_thread->Object );
return RTEMS_SUCCESSFUL;