summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-05-22 09:31:13 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-05-23 08:57:32 +0200
commit4edf348c3395560bcaaf3c020968e427f5683d28 (patch)
treebb132a0862f916a58de14df14eb32d6c7d5df20e /cpukit/score/src
parentdecff888363d23dac5bfe1f10e46fb7a280eaf23 (diff)
downloadrtems-4edf348c3395560bcaaf3c020968e427f5683d28.tar.bz2
score: PR2179: Fix initially locked PCP mutexes
Elevate the priority of the creating task to the ceiling priority in case a semaphore is created as initially locked.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/coremutex.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c
index 96b11c9cd1..e13c7aafac 100644
--- a/cpukit/score/src/coremutex.c
+++ b/cpukit/score/src/coremutex.c
@@ -43,10 +43,20 @@ CORE_mutex_Status _CORE_mutex_Initialize(
the_mutex->holder = executing;
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
+ Priority_Control ceiling = the_mutex->Attributes.priority_ceiling;
+
+ /*
+ * 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.
+ */
+ _Thread_Disable_dispatch();
+
+ if ( executing->current_priority < ceiling ) {
+ _Thread_Enable_dispatch();
+ return CORE_MUTEX_STATUS_CEILING_VIOLATED;
+ }
- if ( executing->current_priority <
- the_mutex->Attributes.priority_ceiling )
- return CORE_MUTEX_STATUS_CEILING_VIOLATED;
#ifdef __RTEMS_STRICT_ORDER_MUTEX__
_Chain_Prepend_unprotected( &executing->lock_mutex,
&the_mutex->queue.lock_queue );
@@ -54,6 +64,9 @@ CORE_mutex_Status _CORE_mutex_Initialize(
#endif
executing->resource_count++;
+
+ _Thread_Change_priority( executing, ceiling, false );
+ _Thread_Enable_dispatch();
}
} else {
the_mutex->nest_count = 0;