[PATCH 02/14] score: Ensure matching lock acquire and release
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed May 11 13:23:29 UTC 2016
Ensure matching lock acquire and release for SMP locks if RTEMS_DEBUG is
defined.
---
cpukit/score/include/rtems/score/smplock.h | 7 ++++---
cpukit/score/src/smplock.c | 13 ++++++++++++-
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/cpukit/score/include/rtems/score/smplock.h b/cpukit/score/include/rtems/score/smplock.h
index 0cefe38..47797d3 100644
--- a/cpukit/score/include/rtems/score/smplock.h
+++ b/cpukit/score/include/rtems/score/smplock.h
@@ -398,6 +398,9 @@ typedef struct {
*/
typedef struct {
ISR_Level isr_level;
+#if defined( RTEMS_DEBUG )
+ SMP_lock_Control *lock_used_for_acquire;
+#endif
#if defined( RTEMS_PROFILING )
SMP_lock_Stats_context Stats_context;
#endif
@@ -578,11 +581,8 @@ void _SMP_lock_Release_and_ISR_enable(
SMP_lock_Control *lock,
SMP_lock_Context *context
);
-
-static inline void _SMP_lock_Release_and_ISR_enable_body(
#else
static inline void _SMP_lock_Release_and_ISR_enable(
-#endif
SMP_lock_Control *lock,
SMP_lock_Context *context
)
@@ -590,6 +590,7 @@ static inline void _SMP_lock_Release_and_ISR_enable(
_SMP_lock_Release( lock, context );
_ISR_Enable_without_giant( context->isr_level );
}
+#endif
#if defined( RTEMS_DEBUG )
/**
diff --git a/cpukit/score/src/smplock.c b/cpukit/score/src/smplock.c
index 35b1930..e426c2a 100644
--- a/cpukit/score/src/smplock.c
+++ b/cpukit/score/src/smplock.c
@@ -40,6 +40,9 @@ void _SMP_lock_Acquire(
SMP_lock_Context *context
)
{
+#if defined(RTEMS_DEBUG)
+ context->lock_used_for_acquire = lock;
+#endif
_SMP_lock_Acquire_body( lock, context );
#if defined(RTEMS_DEBUG)
lock->owner = _SMP_Get_current_processor();
@@ -52,6 +55,8 @@ void _SMP_lock_Release(
)
{
#if defined(RTEMS_DEBUG)
+ _Assert( context->lock_used_for_acquire == lock );
+ context->lock_used_for_acquire = NULL;
_Assert( lock->owner == _SMP_Get_current_processor() );
lock->owner = SMP_LOCK_NO_OWNER;
#endif
@@ -63,6 +68,9 @@ void _SMP_lock_ISR_disable_and_acquire(
SMP_lock_Context *context
)
{
+#if defined(RTEMS_DEBUG)
+ context->lock_used_for_acquire = lock;
+#endif
_SMP_lock_ISR_disable_and_acquire_body( lock, context );
#if defined(RTEMS_DEBUG)
lock->owner = _SMP_Get_current_processor();
@@ -75,10 +83,13 @@ void _SMP_lock_Release_and_ISR_enable(
)
{
#if defined(RTEMS_DEBUG)
+ _Assert( context->lock_used_for_acquire == lock );
+ context->lock_used_for_acquire = NULL;
_Assert( lock->owner == _SMP_Get_current_processor() );
lock->owner = SMP_LOCK_NO_OWNER;
#endif
- _SMP_lock_Release_and_ISR_enable_body( lock, context );
+ _SMP_lock_Release_body( lock, context );
+ _ISR_Enable_without_giant( context->isr_level );
}
#if defined(RTEMS_DEBUG)
--
1.8.4.5
More information about the devel
mailing list