summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coremutexseize.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src/coremutexseize.c')
-rw-r--r--cpukit/score/src/coremutexseize.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 4ecb702305..94c480d054 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -53,17 +53,28 @@ void _CORE_mutex_Seize_interrupt_blocking(
ISR_lock_Context *lock_context
)
{
- _Thread_Disable_dispatch();
+#if !defined(RTEMS_SMP)
+ /*
+ * We must disable thread dispatching here since we enable the interrupts for
+ * priority inheritance mutexes.
+ */
+ _Thread_Dispatch_disable();
+#endif
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) {
Thread_Control *holder = the_mutex->holder;
+#if !defined(RTEMS_SMP)
/*
- * To enable interrupts here works only since we own the Giant lock and
- * only threads are allowed to seize and surrender mutexes with the
- * priority inheritance protocol.
+ * To enable interrupts here works only since exactly one executing thread
+ * exists and only threads are allowed to seize and surrender mutexes with
+ * the priority inheritance protocol. On SMP configurations more than one
+ * executing thread may exist, so here we must not release the lock, since
+ * otherwise the current holder may be no longer the holder of the mutex
+ * once we released the lock.
*/
- _ISR_lock_ISR_enable( lock_context );
+ _Thread_queue_Release( &the_mutex->Wait_queue, lock_context );
+#endif
_Scheduler_Change_priority_if_higher(
_Scheduler_Get( holder ),
@@ -72,10 +83,11 @@ void _CORE_mutex_Seize_interrupt_blocking(
false
);
- _ISR_lock_ISR_disable( lock_context );
+#if !defined(RTEMS_SMP)
+ _Thread_queue_Acquire( &the_mutex->Wait_queue, lock_context );
+#endif
}
- _Thread_queue_Acquire_critical( &the_mutex->Wait_queue, lock_context );
_Thread_queue_Enqueue_critical(
&the_mutex->Wait_queue,
executing,
@@ -85,6 +97,8 @@ void _CORE_mutex_Seize_interrupt_blocking(
lock_context
);
- _Thread_Enable_dispatch();
+#if !defined(RTEMS_SMP)
+ _Thread_Dispatch_enable( _Per_CPU_Get() );
+#endif
}