summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coremutexsurrender.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/coremutexsurrender.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 '')
-rw-r--r--cpukit/score/src/coremutexsurrender.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c
index 3f0cd8619c..d5dde1e8e6 100644
--- a/cpukit/score/src/coremutexsurrender.c
+++ b/cpukit/score/src/coremutexsurrender.c
@@ -207,14 +207,10 @@ CORE_mutex_Status _CORE_mutex_Surrender(
case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
_CORE_mutex_Push_priority( the_mutex, the_thread );
the_thread->resource_count++;
- if (the_mutex->Attributes.priority_ceiling <
- the_thread->current_priority){
- _Thread_Change_priority(
- the_thread,
- the_mutex->Attributes.priority_ceiling,
- false
- );
- }
+ _Thread_Raise_priority(
+ the_thread,
+ the_mutex->Attributes.priority_ceiling
+ );
break;
}
}
@@ -246,13 +242,20 @@ CORE_mutex_Status _CORE_mutex_Surrender(
* inherited priority must be lowered if this is the last
* mutex (i.e. resource) this task has.
*/
- if ( !_Thread_Owns_resources( holder ) &&
- holder->real_priority != holder->current_priority ) {
- Per_CPU_Control *cpu_self;
+ if ( !_Thread_Owns_resources( holder ) ) {
+ /*
+ * Ensure that the holder resource count is visible to all other processors
+ * and that we read the latest priority restore hint.
+ */
+ _Atomic_Fence( ATOMIC_ORDER_ACQ_REL );
- cpu_self = _Thread_Dispatch_disable();
- _Thread_Change_priority( holder, holder->real_priority, true );
- _Thread_Dispatch_enable( cpu_self );
+ if ( holder->priority_restore_hint ) {
+ Per_CPU_Control *cpu_self;
+
+ cpu_self = _Thread_Dispatch_disable();
+ _Thread_Restore_priority( holder );
+ _Thread_Dispatch_enable( cpu_self );
+ }
}
return CORE_MUTEX_STATUS_SUCCESSFUL;