score: Use processor mask in _SMP_Multicast_action

Processor_mask is the internal data type to deal with processor sets.
This commit is contained in:
Sebastian Huber
2019-04-09 10:58:35 +02:00
parent e97b7c9a7a
commit df8d7bd76f
9 changed files with 403 additions and 66 deletions

View File

@@ -249,20 +249,19 @@ void _SMP_Send_message_multicast(
typedef void ( *SMP_Action_handler )( void *arg );
/**
* @brief Initiates an SMP multicast action to a set of processors.
* @brief Initiates an SMP multicast action to a set of target processors.
*
* The current processor may be part of the set.
* The current processor may be part of the set.
*
* @param[in] setsize The size of the set of target processors of the message.
* @param[in] cpus The set of target processors of the message.
* @param[in] handler The multicast action handler.
* @param[in] arg The multicast action argument.
* @param targets The set of target processors for the action. If @c NULL,
* then the action will be performed on all online processors.
* @param handler The multicast action handler.
* @param arg The multicast action argument.
*/
void _SMP_Multicast_action(
const size_t setsize,
const cpu_set_t *cpus,
SMP_Action_handler handler,
void *arg
const Processor_mask *targets,
SMP_Action_handler handler,
void *arg
);
/**

View File

@@ -89,14 +89,12 @@ _SMP_Multicasts_try_process( void )
}
void _SMP_Multicast_action(
const size_t setsize,
const cpu_set_t *cpus,
SMP_Action_handler handler,
void *arg
const Processor_mask *targets,
SMP_Action_handler handler,
void *arg
)
{
SMP_Multicast_action node;
Processor_mask targets;
ISR_lock_Context lock_context;
uint32_t i;
@@ -105,29 +103,21 @@ void _SMP_Multicast_action(
return;
}
if( cpus == NULL ) {
_Processor_mask_Assign( &targets, _SMP_Get_online_processors() );
} else {
_Processor_mask_Zero( &targets );
for ( i = 0; i < _SMP_Get_processor_maximum(); ++i ) {
if ( CPU_ISSET_S( i, setsize, cpus ) ) {
_Processor_mask_Set( &targets, i );
}
}
if( targets == NULL ) {
targets = _SMP_Get_online_processors();
}
_Chain_Initialize_node( &node.Node );
node.handler = handler;
node.arg = arg;
_Processor_mask_Assign( &node.targets, &targets );
_Processor_mask_Assign( &node.targets, targets );
_Atomic_Store_ulong( &node.done, 0, ATOMIC_ORDER_RELAXED );
_ISR_lock_ISR_disable_and_acquire( &_SMP_Multicast.Lock, &lock_context );
_Chain_Prepend_unprotected( &_SMP_Multicast.Actions, &node.Node );
_ISR_lock_Release_and_ISR_enable( &_SMP_Multicast.Lock, &lock_context );
_SMP_Send_message_multicast( &targets, SMP_MESSAGE_MULTICAST_ACTION );
_SMP_Send_message_multicast( targets, SMP_MESSAGE_MULTICAST_ACTION );
_SMP_Multicasts_try_process();
while ( _Atomic_Load_ulong( &node.done, ATOMIC_ORDER_ACQUIRE ) == 0 ) {