diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-11-03 17:00:28 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-11-04 10:54:52 +0100 |
commit | 9cd53495d292ace4df6101d2a6f80c34b3c42e8d (patch) | |
tree | 1b02b843bf1d46f89c72ce55ebf84c7efa5c355f /cpukit/score/include/rtems/score/smplock.h | |
parent | Size optimization for resource snapshots (diff) | |
download | rtems-9cd53495d292ace4df6101d2a6f80c34b3c42e8d.tar.bz2 |
score: Default to non-inline SMP lock ops
Use non-inline SMP lock acquire and release operations by default.
Provide inline variants for the hot spots, e.g. mutex acquire/release.
Diffstat (limited to 'cpukit/score/include/rtems/score/smplock.h')
-rw-r--r-- | cpukit/score/include/rtems/score/smplock.h | 118 |
1 files changed, 64 insertions, 54 deletions
diff --git a/cpukit/score/include/rtems/score/smplock.h b/cpukit/score/include/rtems/score/smplock.h index eddbb32b15..c2214e6ab1 100644 --- a/cpukit/score/include/rtems/score/smplock.h +++ b/cpukit/score/include/rtems/score/smplock.h @@ -28,8 +28,9 @@ #include <rtems/score/smplockticket.h> #include <rtems/score/isrlevel.h> -#if defined(RTEMS_PROFILING) || defined(RTEMS_DEBUG) -#define RTEMS_SMP_LOCK_DO_NOT_INLINE +#if defined(RTEMS_DEBUG) +#include <rtems/score/assert.h> +#include <rtems/score/smp.h> #endif #ifdef __cplusplus @@ -116,6 +117,22 @@ typedef struct { #define SMP_LOCK_INITIALIZER( name ) { SMP_TICKET_LOCK_INITIALIZER } #endif +static inline void _SMP_lock_Initialize_inline( + SMP_lock_Control *lock, + const char *name +) +{ + _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 + (void) name; +#endif +} + /** * @brief Initializes an SMP lock. * @@ -128,26 +145,22 @@ typedef struct { #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) void _SMP_lock_Initialize( SMP_lock_Control *lock, - const char *name + const char * name ); - -static inline void _SMP_lock_Initialize_body( #else static inline void _SMP_lock_Initialize( -#endif SMP_lock_Control *lock, - const char *name + const char *name ) { - _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 - (void) name; + _SMP_lock_Initialize_inline( lock, name ); +} #endif + +static inline void _SMP_lock_Destroy_inline( SMP_lock_Control *lock ) +{ + _SMP_ticket_lock_Destroy( &lock->Ticket_lock ); + _SMP_lock_Stats_destroy( &lock->Stats ); } /** @@ -159,14 +172,31 @@ static inline void _SMP_lock_Initialize( */ #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) void _SMP_lock_Destroy( SMP_lock_Control *lock ); - -static inline void _SMP_lock_Destroy_body( SMP_lock_Control *lock ) #else static inline void _SMP_lock_Destroy( SMP_lock_Control *lock ) +{ + _SMP_lock_Destroy_inline( lock ); +} #endif + +static inline void _SMP_lock_Acquire_inline( + SMP_lock_Control *lock, + SMP_lock_Context *context +) { - _SMP_ticket_lock_Destroy( &lock->Ticket_lock ); - _SMP_lock_Stats_destroy( &lock->Stats ); +#if defined(RTEMS_DEBUG) + context->lock_used_for_acquire = lock; +#else + (void) context; +#endif + _SMP_ticket_lock_Acquire( + &lock->Ticket_lock, + &lock->Stats, + &context->Stats_context + ); +#if defined(RTEMS_DEBUG) + lock->owner = _SMP_Get_current_processor(); +#endif } /** @@ -180,24 +210,26 @@ static inline void _SMP_lock_Destroy( SMP_lock_Control *lock ) * @param[in] context The local SMP lock context for an acquire and release * pair. */ -#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) void _SMP_lock_Acquire( SMP_lock_Control *lock, SMP_lock_Context *context ); -static inline void _SMP_lock_Acquire_body( -#else -static inline void _SMP_lock_Acquire( -#endif +static inline void _SMP_lock_Release_inline( SMP_lock_Control *lock, SMP_lock_Context *context ) { +#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; +#else (void) context; - _SMP_ticket_lock_Acquire( +#endif + _SMP_ticket_lock_Release( &lock->Ticket_lock, - &lock->Stats, &context->Stats_context ); } @@ -209,25 +241,18 @@ static inline void _SMP_lock_Acquire( * @param[in] context The local SMP lock context for an acquire and release * pair. */ -#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) void _SMP_lock_Release( SMP_lock_Control *lock, SMP_lock_Context *context ); -static inline void _SMP_lock_Release_body( -#else -static inline void _SMP_lock_Release( -#endif +static inline void _SMP_lock_ISR_disable_and_acquire_inline( SMP_lock_Control *lock, SMP_lock_Context *context ) { - (void) context; - _SMP_ticket_lock_Release( - &lock->Ticket_lock, - &context->Stats_context - ); + _ISR_Local_disable( context->isr_level ); + _SMP_lock_Acquire_inline( lock, context ); } /** @@ -237,22 +262,18 @@ static inline void _SMP_lock_Release( * @param[in] context The local SMP lock context for an acquire and release * pair. */ -#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) void _SMP_lock_ISR_disable_and_acquire( SMP_lock_Control *lock, SMP_lock_Context *context ); -static inline void _SMP_lock_ISR_disable_and_acquire_body( -#else -static inline void _SMP_lock_ISR_disable_and_acquire( -#endif +static inline void _SMP_lock_Release_and_ISR_enable_inline( SMP_lock_Control *lock, SMP_lock_Context *context ) { - _ISR_Local_disable( context->isr_level ); - _SMP_lock_Acquire( lock, context ); + _SMP_lock_Release_inline( lock, context ); + _ISR_Local_enable( context->isr_level ); } /** @@ -262,21 +283,10 @@ static inline void _SMP_lock_ISR_disable_and_acquire( * @param[in] context The local SMP lock context for an acquire and release * pair. */ -#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) void _SMP_lock_Release_and_ISR_enable( SMP_lock_Control *lock, SMP_lock_Context *context ); -#else -static inline void _SMP_lock_Release_and_ISR_enable( - SMP_lock_Control *lock, - SMP_lock_Context *context -) -{ - _SMP_lock_Release( lock, context ); - _ISR_Local_enable( context->isr_level ); -} -#endif #if defined(RTEMS_DEBUG) /** |