summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coremutex.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src/coremutex.c')
-rw-r--r--cpukit/score/src/coremutex.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c
index b5e8a5ed4b..6bb535a8ec 100644
--- a/cpukit/score/src/coremutex.c
+++ b/cpukit/score/src/coremutex.c
@@ -48,16 +48,22 @@ CORE_mutex_Status _CORE_mutex_Initialize(
if ( is_priority_ceiling ||
_CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) {
Priority_Control ceiling = the_mutex->Attributes.priority_ceiling;
+ Per_CPU_Control *cpu_self;
+
+ /* The mutex initialization is only protected by the allocator lock */
+ cpu_self = _Thread_Dispatch_disable();
/*
- * 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 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.
*/
- _Thread_Disable_dispatch();
-
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;
}
@@ -70,10 +76,10 @@ 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_Enable_dispatch();
+ _Thread_Dispatch_enable( cpu_self );
}
} else {
the_mutex->nest_count = 0;
@@ -83,8 +89,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
_Thread_queue_Initialize(
&the_mutex->Wait_queue,
_CORE_mutex_Is_fifo( the_mutex_attributes ) ?
- THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY,
- CORE_MUTEX_TIMEOUT
+ THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY
);
return CORE_MUTEX_STATUS_SUCCESSFUL;