Changeset 18d45d9 in rtems


Ignore:
Timestamp:
Apr 11, 2019, 10:10:53 AM (3 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
e97b7c9a
Parents:
5ca8190b
git-author:
Sebastian Huber <sebastian.huber@…> (04/11/19 10:10:53)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/12/19 07:12:03)
Message:

score: Add _ISR_lock_Set_name()

Add _ISR_lock_Set_name() to optimize the initialization of
zero-initialized locks.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/score/isrlock.h

    r5ca8190b r18d45d9  
    198198#else
    199199  #define _ISR_lock_Destroy( _lock )
     200#endif
     201
     202/**
     203 * @brief Sets the name of an ISR lock.
     204 *
     205 * @param[out] _lock The ISR lock control.
     206 * @param _name The name for the ISR lock.  This name must be a string
     207 *   persistent throughout the life time of this lock.  The name is only used
     208 *   if profiling is enabled.
     209 */
     210#if defined( RTEMS_SMP )
     211  #define _ISR_lock_Set_name( _lock, _name ) \
     212    _SMP_lock_Set_name( &( _lock )->Lock, _name )
     213#else
     214  #define _ISR_lock_Set_name( _lock, _name )
    200215#endif
    201216
  • cpukit/include/rtems/score/smplock.h

    r5ca8190b r18d45d9  
    150150void _SMP_lock_Initialize(
    151151  SMP_lock_Control *lock,
    152   const char *      name
     152  const char       *name
    153153);
    154154#else
     
    176176  _SMP_lock_Destroy_inline( lock )
    177177#endif
     178
     179/**
     180 * @brief Sets the name of an SMP lock.
     181 *
     182 * @param[out] lock The SMP lock control.
     183 * @param name The name for the SMP lock statistics.  This name must be
     184 *   persistent throughout the life time of this statistics block.
     185 */
     186static inline void _SMP_lock_Set_name(
     187  SMP_lock_Control *lock,
     188  const char       *name
     189)
     190{
     191#if defined(RTEMS_PROFILING)
     192  lock->Stats.name = name;
     193#else
     194  (void) name;
     195#endif
     196}
    178197
    179198#if defined(RTEMS_DEBUG)
  • cpukit/score/src/smp.c

    r5ca8190b r18d45d9  
    115115
    116116  for ( cpu_index = 0 ; cpu_index < cpu_config_max; ++cpu_index ) {
    117     Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
    118 
    119     _ISR_lock_Initialize( &cpu->Watchdog.Lock, "Watchdog" );
     117    Per_CPU_Control *cpu;
     118
     119    cpu = _Per_CPU_Get_by_index( cpu_index );
    120120    _SMP_ticket_lock_Initialize( &cpu->Lock );
    121121    _SMP_lock_Stats_initialize( &cpu->Lock_stats, "Per-CPU" );
     122    _ISR_lock_Set_name( &cpu->Watchdog.Lock, "Per-CPU Watchdog" );
    122123    _Chain_Initialize_empty( &cpu->Threads_in_need_for_help );
    123124  }
  • testsuites/sptests/sp37/init.c

    r5ca8190b r18d45d9  
    170170static void test_isr_locks( void )
    171171{
     172  static const char name[] = "test";
    172173  ISR_Level normal_interrupt_level = _ISR_Get_level();
    173   ISR_lock_Control initialized = ISR_LOCK_INITIALIZER("test");
     174  ISR_lock_Control initialized = ISR_LOCK_INITIALIZER( name );
     175  ISR_lock_Control zero_initialized;
    174176  union {
    175177    ISR_lock_Control lock;
     
    178180  ISR_lock_Context lock_context;
    179181  size_t i;
    180   const uint8_t *initialized_bytes;
     182  const uint8_t *bytes;
    181183  ISR_Level interrupt_level;
    182184
    183185  memset( &container, 0xff, sizeof( container ) );
    184   _ISR_lock_Initialize( &container.lock, "test" );
    185   initialized_bytes = (const uint8_t *) &initialized;
     186  _ISR_lock_Initialize( &container.lock, name );
     187  bytes = (const uint8_t *) &initialized;
    186188
    187189  for ( i = 0; i < sizeof( container ); ++i ) {
    188190    if ( container.bytes[ i ] != 0xff ) {
    189       rtems_test_assert( container.bytes[ i ] == initialized_bytes[ i] );
     191      rtems_test_assert( container.bytes[ i ] == bytes[ i ] );
     192    }
     193  }
     194
     195  memset( &zero_initialized, 0, sizeof( zero_initialized ) );
     196  _ISR_lock_Set_name( &zero_initialized, name );
     197  bytes = (const uint8_t *) &zero_initialized;
     198
     199  for ( i = 0; i < sizeof( container ); ++i ) {
     200    if ( container.bytes[ i ] != 0xff ) {
     201      rtems_test_assert( container.bytes[ i ] == bytes[ i ] );
    190202    }
    191203  }
Note: See TracChangeset for help on using the changeset viewer.