summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-04-11 12:10:53 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-04-12 09:12:03 +0200
commit18d45d9d25beceedcc3e34eea3d28f87fa200e76 (patch)
treef27c51849fe3ae495f60e015602d7f4418be5f56
parentscore: Remove unused macros (diff)
downloadrtems-18d45d9d25beceedcc3e34eea3d28f87fa200e76.tar.bz2
score: Add _ISR_lock_Set_name()
Add _ISR_lock_Set_name() to optimize the initialization of zero-initialized locks.
-rw-r--r--cpukit/include/rtems/score/isrlock.h15
-rw-r--r--cpukit/include/rtems/score/smplock.h21
-rw-r--r--cpukit/score/src/smp.c5
-rw-r--r--testsuites/sptests/sp37/init.c22
4 files changed, 55 insertions, 8 deletions
diff --git a/cpukit/include/rtems/score/isrlock.h b/cpukit/include/rtems/score/isrlock.h
index b1aea62bf0..de85286de7 100644
--- a/cpukit/include/rtems/score/isrlock.h
+++ b/cpukit/include/rtems/score/isrlock.h
@@ -200,6 +200,21 @@ RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(
#endif
/**
+ * @brief Sets the name of an ISR lock.
+ *
+ * @param[out] _lock The ISR lock control.
+ * @param _name The name for the ISR lock. This name must be a string
+ * persistent throughout the life time of this lock. The name is only used
+ * if profiling is enabled.
+ */
+#if defined( RTEMS_SMP )
+ #define _ISR_lock_Set_name( _lock, _name ) \
+ _SMP_lock_Set_name( &( _lock )->Lock, _name )
+#else
+ #define _ISR_lock_Set_name( _lock, _name )
+#endif
+
+/**
* @brief Acquires an ISR lock.
*
* Interrupts will be disabled. On SMP configurations this function acquires
diff --git a/cpukit/include/rtems/score/smplock.h b/cpukit/include/rtems/score/smplock.h
index 1c37db465b..b1f5a6de28 100644
--- a/cpukit/include/rtems/score/smplock.h
+++ b/cpukit/include/rtems/score/smplock.h
@@ -149,7 +149,7 @@ static inline void _SMP_lock_Initialize_inline(
#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
void _SMP_lock_Initialize(
SMP_lock_Control *lock,
- const char * name
+ const char *name
);
#else
#define _SMP_lock_Initialize( lock, name ) \
@@ -176,6 +176,25 @@ void _SMP_lock_Destroy( SMP_lock_Control *lock );
_SMP_lock_Destroy_inline( lock )
#endif
+/**
+ * @brief Sets the name of an SMP lock.
+ *
+ * @param[out] lock The SMP lock control.
+ * @param name The name for the SMP lock statistics. This name must be
+ * persistent throughout the life time of this statistics block.
+ */
+static inline void _SMP_lock_Set_name(
+ SMP_lock_Control *lock,
+ const char *name
+)
+{
+#if defined(RTEMS_PROFILING)
+ lock->Stats.name = name;
+#else
+ (void) name;
+#endif
+}
+
#if defined(RTEMS_DEBUG)
static inline uint32_t _SMP_lock_Who_am_I( void )
{
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index 780b33c740..822ecfd4ff 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -114,11 +114,12 @@ void _SMP_Handler_initialize( void )
cpu_config_max = rtems_configuration_get_maximum_processors();
for ( cpu_index = 0 ; cpu_index < cpu_config_max; ++cpu_index ) {
- Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
+ Per_CPU_Control *cpu;
- _ISR_lock_Initialize( &cpu->Watchdog.Lock, "Watchdog" );
+ cpu = _Per_CPU_Get_by_index( cpu_index );
_SMP_ticket_lock_Initialize( &cpu->Lock );
_SMP_lock_Stats_initialize( &cpu->Lock_stats, "Per-CPU" );
+ _ISR_lock_Set_name( &cpu->Watchdog.Lock, "Per-CPU Watchdog" );
_Chain_Initialize_empty( &cpu->Threads_in_need_for_help );
}
diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c
index 1a63298d3b..22c7d4f2ef 100644
--- a/testsuites/sptests/sp37/init.c
+++ b/testsuites/sptests/sp37/init.c
@@ -169,24 +169,36 @@ static void test_isr_level( void )
static void test_isr_locks( void )
{
+ static const char name[] = "test";
ISR_Level normal_interrupt_level = _ISR_Get_level();
- ISR_lock_Control initialized = ISR_LOCK_INITIALIZER("test");
+ ISR_lock_Control initialized = ISR_LOCK_INITIALIZER( name );
+ ISR_lock_Control zero_initialized;
union {
ISR_lock_Control lock;
uint8_t bytes[ sizeof( ISR_lock_Control ) ];
} container;
ISR_lock_Context lock_context;
size_t i;
- const uint8_t *initialized_bytes;
+ const uint8_t *bytes;
ISR_Level interrupt_level;
memset( &container, 0xff, sizeof( container ) );
- _ISR_lock_Initialize( &container.lock, "test" );
- initialized_bytes = (const uint8_t *) &initialized;
+ _ISR_lock_Initialize( &container.lock, name );
+ bytes = (const uint8_t *) &initialized;
for ( i = 0; i < sizeof( container ); ++i ) {
if ( container.bytes[ i ] != 0xff ) {
- rtems_test_assert( container.bytes[ i ] == initialized_bytes[ i] );
+ rtems_test_assert( container.bytes[ i ] == bytes[ i ] );
+ }
+ }
+
+ memset( &zero_initialized, 0, sizeof( zero_initialized ) );
+ _ISR_lock_Set_name( &zero_initialized, name );
+ bytes = (const uint8_t *) &zero_initialized;
+
+ for ( i = 0; i < sizeof( container ); ++i ) {
+ if ( container.bytes[ i ] != 0xff ) {
+ rtems_test_assert( container.bytes[ i ] == bytes[ i ] );
}
}