diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-11 13:41:55 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-11 13:52:08 +0100 |
commit | 3d35bc00d8483a748c819012c860550271c37b9a (patch) | |
tree | c202f5b62d78440c3e3b00cddffbda75da966599 /cpukit | |
parent | score: Optimize thread state values (diff) | |
download | rtems-3d35bc00d8483a748c819012c860550271c37b9a.tar.bz2 |
score: Improve SMP lock debug support
The CPU index starts with zero. Increment it by one, to allow global
SMP locks to reside in the BSS section.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/score/include/rtems/score/smplock.h | 17 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadqimpl.h | 2 | ||||
-rw-r--r-- | cpukit/score/src/smplock.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadq.c | 4 |
4 files changed, 18 insertions, 7 deletions
diff --git a/cpukit/score/include/rtems/score/smplock.h b/cpukit/score/include/rtems/score/smplock.h index 28022041ed..a156edfd92 100644 --- a/cpukit/score/include/rtems/score/smplock.h +++ b/cpukit/score/include/rtems/score/smplock.h @@ -98,7 +98,7 @@ typedef struct { } SMP_lock_Context; #if defined(RTEMS_DEBUG) -#define SMP_LOCK_NO_OWNER 0xffffffff +#define SMP_LOCK_NO_OWNER 0 #endif /** @@ -176,6 +176,17 @@ void _SMP_lock_Destroy( SMP_lock_Control *lock ); _SMP_lock_Destroy_inline( lock ) #endif +#if defined(RTEMS_DEBUG) +static inline uint32_t _SMP_lock_Who_am_I( void ) +{ + /* + * The CPU index starts with zero. Increment it by one, to allow global SMP + * locks to reside in the BSS section. + */ + return _SMP_Get_current_processor() + 1; +} +#endif + static inline void _SMP_lock_Acquire_inline( SMP_lock_Control *lock, SMP_lock_Context *context @@ -192,7 +203,7 @@ static inline void _SMP_lock_Acquire_inline( &context->Stats_context ); #if defined(RTEMS_DEBUG) - lock->owner = _SMP_Get_current_processor(); + lock->owner = _SMP_lock_Who_am_I(); #endif } @@ -220,7 +231,7 @@ static inline void _SMP_lock_Release_inline( #if defined(RTEMS_DEBUG) _Assert( context->lock_used_for_acquire == lock ); context->lock_used_for_acquire = NULL; - _Assert( lock->owner == _SMP_Get_current_processor() ); + _Assert( lock->owner == _SMP_lock_Who_am_I() ); lock->owner = SMP_LOCK_NO_OWNER; #else (void) context; diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h index fc907d3936..1558489fca 100644 --- a/cpukit/score/include/rtems/score/threadqimpl.h +++ b/cpukit/score/include/rtems/score/threadqimpl.h @@ -467,7 +467,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_lock_owner( ) { #if defined(RTEMS_SMP) - return the_thread_queue->owner == _SMP_Get_current_processor(); + return the_thread_queue->owner == _SMP_lock_Who_am_I(); #else return _ISR_Get_level() != 0; #endif diff --git a/cpukit/score/src/smplock.c b/cpukit/score/src/smplock.c index e921837455..b9c7f6eed6 100644 --- a/cpukit/score/src/smplock.c +++ b/cpukit/score/src/smplock.c @@ -72,6 +72,6 @@ void _SMP_lock_Release_and_ISR_enable( #if defined(RTEMS_DEBUG) bool _SMP_lock_Is_owner( const SMP_lock_Control *lock ) { - return lock->owner == _SMP_Get_current_processor(); + return lock->owner == _SMP_lock_Who_am_I(); } #endif diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c index d427431adb..b12e3deb49 100644 --- a/cpukit/score/src/threadq.c +++ b/cpukit/score/src/threadq.c @@ -76,7 +76,7 @@ void _Thread_queue_Do_acquire_critical( lock_context ); #if defined(RTEMS_DEBUG) - the_thread_queue->owner = _SMP_Get_current_processor(); + the_thread_queue->owner = _SMP_lock_Who_am_I(); #endif } @@ -92,7 +92,7 @@ void _Thread_queue_Acquire( &queue_context->Lock_context.Lock_context ); #if defined(RTEMS_DEBUG) - the_thread_queue->owner = _SMP_Get_current_processor(); + the_thread_queue->owner = _SMP_lock_Who_am_I(); #endif } |