summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coremutex.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/coremutex.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/coremutex.c')
-rw-r--r--cpukit/score/src/coremutex.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c
index 58c6c42b06..6bb535a8ec 100644
--- a/cpukit/score/src/coremutex.c
+++ b/cpukit/score/src/coremutex.c
@@ -50,15 +50,20 @@ CORE_mutex_Status _CORE_mutex_Initialize(
Priority_Control ceiling = the_mutex->Attributes.priority_ceiling;
Per_CPU_Control *cpu_self;
- /*
- * The mutex initialization is only protected by the allocator lock in
- * general. Disable thread dispatching before the priority check to
- * prevent interference with priority inheritance.
- */
+ /* The mutex initialization is only protected by the allocator lock */
cpu_self = _Thread_Dispatch_disable();
+ /*
+ * The test to check for a ceiling violation is a bit arbitrary. In case
+ * this thread is the owner of a priority inheritance mutex, then it may
+ * get a higher priority later or anytime on SMP configurations.
+ */
if ( is_priority_ceiling && executing->current_priority < ceiling ) {
- _Thread_Enable_dispatch();
+ /*
+ * There is no need to undo the previous work since this error aborts
+ * the object creation.
+ */
+ _Thread_Dispatch_enable( cpu_self );
return CORE_MUTEX_STATUS_CEILING_VIOLATED;
}
@@ -71,7 +76,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
executing->resource_count++;
if ( is_priority_ceiling ) {
- _Thread_Change_priority( executing, ceiling, false );
+ _Thread_Raise_priority( executing, ceiling );
}
_Thread_Dispatch_enable( cpu_self );