diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-09 06:49:53 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-12 13:20:34 +0200 |
commit | 1a9d36b921306eaef671127f281500945f287822 (patch) | |
tree | 136a5da705ae644025823f77e724c7c02c58624f /cpukit/score/include/rtems/score/smplock.h | |
parent | score: Fix CORE mutex initialization (diff) | |
download | rtems-1a9d36b921306eaef671127f281500945f287822.tar.bz2 |
score: Add _ISR_lock_Is_owner()
Diffstat (limited to 'cpukit/score/include/rtems/score/smplock.h')
-rw-r--r-- | cpukit/score/include/rtems/score/smplock.h | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/cpukit/score/include/rtems/score/smplock.h b/cpukit/score/include/rtems/score/smplock.h index f98f38a6a3..0cefe38aa3 100644 --- a/cpukit/score/include/rtems/score/smplock.h +++ b/cpukit/score/include/rtems/score/smplock.h @@ -10,7 +10,7 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2013-2015 embedded brains GmbH + * Copyright (c) 2013, 2016 embedded brains GmbH * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -32,7 +32,7 @@ #include <string.h> #endif -#if defined( RTEMS_PROFILING ) +#if defined( RTEMS_PROFILING ) || defined( RTEMS_DEBUG ) #define RTEMS_SMP_LOCK_DO_NOT_INLINE #endif @@ -373,6 +373,21 @@ static inline void _SMP_ticket_lock_Do_release( */ typedef struct { SMP_ticket_lock_Control Ticket_lock; +#if defined( RTEMS_DEBUG ) + /** + * @brief The index of the owning processor of this lock. + * + * The processor index is used instead of the executing thread, so that this + * works in interrupt and system initialization context. It is assumed that + * thread dispatching is disabled in SMP lock critical sections. + * + * In case the lock is free, then the value of this field is + * SMP_LOCK_NO_OWNER. + * + * @see _SMP_lock_Is_owner(). + */ + uint32_t owner; +#endif #if defined( RTEMS_PROFILING ) SMP_lock_Stats Stats; #endif @@ -388,10 +403,24 @@ typedef struct { #endif } SMP_lock_Context; +#if defined( RTEMS_DEBUG ) +#define SMP_LOCK_NO_OWNER 0xffffffff +#endif + /** * @brief SMP lock control initializer for static initialization. */ -#if defined( RTEMS_PROFILING ) +#if defined( RTEMS_DEBUG ) && defined( RTEMS_PROFILING ) + #define SMP_LOCK_INITIALIZER( name ) \ + { \ + SMP_TICKET_LOCK_INITIALIZER, \ + SMP_LOCK_NO_OWNER, \ + SMP_LOCK_STATS_INITIALIZER( name ) \ + } +#elif defined( RTEMS_DEBUG ) + #define SMP_LOCK_INITIALIZER( name ) \ + { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_NO_OWNER } +#elif defined( RTEMS_PROFILING ) #define SMP_LOCK_INITIALIZER( name ) \ { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_STATS_INITIALIZER( name ) } #else @@ -422,6 +451,9 @@ static inline void _SMP_lock_Initialize( ) { _SMP_ticket_lock_Initialize( &lock->Ticket_lock ); +#if defined( RTEMS_DEBUG ) + lock->owner = SMP_LOCK_NO_OWNER; +#endif #if defined( RTEMS_PROFILING ) _SMP_lock_Stats_initialize( &lock->Stats, name ); #else @@ -559,6 +591,16 @@ static inline void _SMP_lock_Release_and_ISR_enable( _ISR_Enable_without_giant( context->isr_level ); } +#if defined( RTEMS_DEBUG ) +/** + * @brief Returns true, if the SMP lock is owned by the current processor, + * otherwise false. + * + * @param[in] lock The SMP lock control. + */ +bool _SMP_lock_Is_owner( const SMP_lock_Control *lock ); +#endif + #if defined( RTEMS_PROFILING ) typedef struct { |