summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coremutexseize.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-27 14:43:19 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-30 16:16:21 +0200
commit93306058c0417b1c6e950b44ef279e096062dfba (patch)
tree1a3326d052169d2aec4c4acdd894589d5d84614c /cpukit/score/src/coremutexseize.c
parentscore: Add _Thread_queue_Context_set_MP_callout() (diff)
downloadrtems-93306058c0417b1c6e950b44ef279e096062dfba.tar.bz2
score: _CORE_mutex_Check_dispatch_for_seize()
Move the safety check performed by _CORE_mutex_Check_dispatch_for_seize() out of the performance critical path and generalize it. Blocking on a thread queue with an unexpected thread dispatch disabled level is illegal in all system states. Add the expected thread dispatch disable level (which may be 1 or 2 depending on the operation) to Thread_queue_Context and use it in _Thread_queue_Enqueue_critical().
Diffstat (limited to 'cpukit/score/src/coremutexseize.c')
-rw-r--r--cpukit/score/src/coremutexseize.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 0fc63f4693..7b8b603d9b 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -18,17 +18,15 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/score/isr.h>
#include <rtems/score/coremuteximpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/thread.h>
Status_Control _CORE_mutex_Seize_interrupt_blocking(
- CORE_mutex_Control *the_mutex,
- Thread_Control *executing,
- Watchdog_Interval timeout,
- ISR_lock_Context *lock_context
+ CORE_mutex_Control *the_mutex,
+ Thread_Control *executing,
+ Watchdog_Interval timeout,
+ Thread_queue_Context *queue_context
)
{
#if !defined(RTEMS_SMP)
@@ -51,23 +49,30 @@ Status_Control _CORE_mutex_Seize_interrupt_blocking(
* 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 );
+ _CORE_mutex_Release( the_mutex, queue_context );
#endif
_Thread_Inherit_priority( holder, executing );
#if !defined(RTEMS_SMP)
- _Thread_queue_Acquire( &the_mutex->Wait_queue, lock_context );
+ _ISR_lock_ISR_disable( &queue_context->Lock_context );
+ _CORE_mutex_Acquire_critical( the_mutex, queue_context );
#endif
}
+#if defined(RTEMS_SMP)
+ _Thread_queue_Context_set_expected_level( queue_context, 1 );
+#else
+ _Thread_queue_Context_set_expected_level( queue_context, 2 );
+#endif
+
_Thread_queue_Enqueue_critical(
&the_mutex->Wait_queue.Queue,
the_mutex->operations,
executing,
STATES_WAITING_FOR_MUTEX,
timeout,
- lock_context
+ queue_context
);
#if !defined(RTEMS_SMP)