[PATCH 2/3] score: Add function to send a SMP message to a set of CPUs

Joel Sherrill joel.sherrill at oarcorp.com
Thu Jul 3 15:27:22 UTC 2014


This is OK.

I assume there are other use cases to justify adding it.

On 7/3/2014 4:37 AM, Daniel Cederman wrote:
> Make _SMP_Broadcast_message() use the function to send a message to all CPUs except itself.
> ---
>  cpukit/score/include/rtems/score/smpimpl.h |   10 ++++++++++
>  cpukit/score/src/smp.c                     |   15 ++++++++++++---
>  2 files changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/cpukit/score/include/rtems/score/smpimpl.h b/cpukit/score/include/rtems/score/smpimpl.h
> index ba16c8f..51dd34e 100644
> --- a/cpukit/score/include/rtems/score/smpimpl.h
> +++ b/cpukit/score/include/rtems/score/smpimpl.h
> @@ -162,6 +162,16 @@ static inline void _SMP_Inter_processor_interrupt_handler( void )
>  void _SMP_Send_message( uint32_t cpu_index, uint32_t message );
>  
>  /**
> + *  @brief Sends a SMP message to a set of processors.
> + *
> + *  The sending processor may be part of the set.
> + *
> + *  @param[in] cpus The set of target processors of the message.
> + *  @param[in] message The message.
> + */
> +void _SMP_Send_message_cpu_set( const cpu_set_t *cpus, uint32_t message );
> +
> +/**
>   *  @brief Request of others CPUs.
>   *
>   *  This method is invoked by RTEMS when it needs to make a request
> diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
> index 59448a0..f814a38 100644
> --- a/cpukit/score/src/smp.c
> +++ b/cpukit/score/src/smp.c
> @@ -162,19 +162,28 @@ void _SMP_Send_message( uint32_t cpu_index, uint32_t message )
>    _CPU_SMP_Send_interrupt( cpu_index );
>  }
>  
> -void _SMP_Broadcast_message( uint32_t message )
> +void _SMP_Send_message_cpu_set( const cpu_set_t *cpus, uint32_t message )
>  {
>    uint32_t cpu_count = _SMP_Get_processor_count();
> -  uint32_t cpu_index_self = _SMP_Get_current_processor();
>    uint32_t cpu_index;
>  
>    _Assert( _Debug_Is_thread_dispatching_allowed() );
>  
>    for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
> -    if ( cpu_index != cpu_index_self ) {
> +    if ( CPU_ISSET( cpu_index, cpus ) ) {
>        _SMP_Send_message( cpu_index, message );
>      }
>    }
>  }
>  
> +void _SMP_Broadcast_message( uint32_t message )
> +{
> +  cpu_set_t all_cpus_except_self;
> +
> +  CPU_FILL( &all_cpus_except_self );
> +  CPU_CLR( _SMP_Get_current_processor(), &all_cpus_except_self );
> +
> +  _SMP_Send_message_cpu_set( &all_cpus_except_self, message );
> +}
> +
>  SMP_Test_message_handler _SMP_Test_message_handler;

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the devel mailing list