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.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 3fc3765ef4..d5f85c5fad 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -21,7 +21,6 @@
#include <rtems/system.h>
#include <rtems/score/isr.h>
#include <rtems/score/coremuteximpl.h>
-#include <rtems/score/schedulerimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/thread.h>
@@ -53,29 +52,47 @@ void _CORE_mutex_Seize_interrupt_blocking(
ISR_lock_Context *lock_context
)
{
- _Thread_queue_Enter_critical_section( &the_mutex->Wait_queue );
- executing->Wait.queue = &the_mutex->Wait_queue;
- _Thread_Disable_dispatch();
- _ISR_lock_ISR_enable( lock_context );
+#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;
- _Scheduler_Change_priority_if_higher(
- _Scheduler_Get( holder ),
- holder,
- executing->current_priority,
- false
- );
+#if !defined(RTEMS_SMP)
+ /*
+ * 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.
+ */
+ _Thread_queue_Release( &the_mutex->Wait_queue, lock_context );
+#endif
+
+ _Thread_Raise_priority( holder, executing->current_priority );
+
+#if !defined(RTEMS_SMP)
+ _Thread_queue_Acquire( &the_mutex->Wait_queue, lock_context );
+#endif
}
- _Thread_queue_Enqueue(
+ _Thread_queue_Enqueue_critical(
&the_mutex->Wait_queue,
executing,
STATES_WAITING_FOR_MUTEX,
- timeout
+ timeout,
+ CORE_MUTEX_TIMEOUT,
+ lock_context
);
- _Thread_Enable_dispatch();
+#if !defined(RTEMS_SMP)
+ _Thread_Dispatch_enable( _Per_CPU_Get() );
+#endif
}