forked from Imagelibrary/rtems
score: More robust _SMP_Multicast_action()
If the caller already disabled interrupts, then do not disable thread dispatching. Calling _SMP_Multicast_action() with interrupts disabled is a questionable use case.
This commit is contained in:
@@ -218,6 +218,7 @@ void _SMP_Multicast_action(
|
|||||||
Per_CPU_Jobs jobs;
|
Per_CPU_Jobs jobs;
|
||||||
uint32_t cpu_max;
|
uint32_t cpu_max;
|
||||||
Per_CPU_Control *cpu_self;
|
Per_CPU_Control *cpu_self;
|
||||||
|
uint32_t isr_level;
|
||||||
|
|
||||||
cpu_max = _SMP_Get_processor_maximum();
|
cpu_max = _SMP_Get_processor_maximum();
|
||||||
_Assert( cpu_max <= CPU_MAXIMUM_PROCESSORS );
|
_Assert( cpu_max <= CPU_MAXIMUM_PROCESSORS );
|
||||||
@@ -228,9 +229,18 @@ void _SMP_Multicast_action(
|
|||||||
|
|
||||||
jobs.handler = handler;
|
jobs.handler = handler;
|
||||||
jobs.arg = arg;
|
jobs.arg = arg;
|
||||||
|
isr_level = _ISR_Get_level();
|
||||||
|
|
||||||
|
if ( isr_level == 0 ) {
|
||||||
cpu_self = _Thread_Dispatch_disable();
|
cpu_self = _Thread_Dispatch_disable();
|
||||||
|
} else {
|
||||||
|
cpu_self = _Per_CPU_Get();
|
||||||
|
}
|
||||||
|
|
||||||
_SMP_Issue_action_jobs( targets, &jobs, cpu_max );
|
_SMP_Issue_action_jobs( targets, &jobs, cpu_max );
|
||||||
_SMP_Wait_for_action_jobs( targets, &jobs, cpu_max, cpu_self );
|
_SMP_Wait_for_action_jobs( targets, &jobs, cpu_max, cpu_self );
|
||||||
|
|
||||||
|
if ( isr_level == 0 ) {
|
||||||
_Thread_Dispatch_enable( cpu_self );
|
_Thread_Dispatch_enable( cpu_self );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -126,15 +126,12 @@ static void call_tests_isr_disabled( SMP_barrier_State *bs )
|
|||||||
broadcast_test_init();
|
broadcast_test_init();
|
||||||
|
|
||||||
for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
|
for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
|
||||||
Per_CPU_Control *cpu_self;
|
|
||||||
ISR_Level isr_level;
|
ISR_Level isr_level;
|
||||||
|
|
||||||
cpu_self = _Thread_Dispatch_disable();
|
|
||||||
_ISR_Local_disable( isr_level );
|
_ISR_Local_disable( isr_level );
|
||||||
barrier( bs );
|
barrier( bs );
|
||||||
( *test_cases[ i ] )();
|
( *test_cases[ i ] )();
|
||||||
_ISR_Local_enable( isr_level );
|
_ISR_Local_enable( isr_level );
|
||||||
_Thread_Dispatch_enable( cpu_self );
|
|
||||||
barrier( bs );
|
barrier( bs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,14 +59,11 @@ static void multicast_action_irq_disabled(
|
|||||||
void *arg
|
void *arg
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Per_CPU_Control *cpu_self;
|
|
||||||
rtems_interrupt_level level;
|
rtems_interrupt_level level;
|
||||||
|
|
||||||
cpu_self = _Thread_Dispatch_disable();
|
|
||||||
rtems_interrupt_local_disable(level);
|
rtems_interrupt_local_disable(level);
|
||||||
_SMP_Multicast_action(targets, handler, arg);
|
_SMP_Multicast_action(targets, handler, arg);
|
||||||
rtems_interrupt_local_enable(level);
|
rtems_interrupt_local_enable(level);
|
||||||
_Thread_Dispatch_enable(cpu_self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void multicast_action_dispatch_disabled(
|
static void multicast_action_dispatch_disabled(
|
||||||
|
|||||||
Reference in New Issue
Block a user