forked from Imagelibrary/rtems
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:
4
bsps/shared/cache/cacheimpl.h
vendored
4
bsps/shared/cache/cacheimpl.h
vendored
@@ -329,7 +329,7 @@ rtems_cache_invalidate_multiple_instruction_lines(
|
|||||||
#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
|
#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
|
||||||
smp_cache_area area = { i_addr, n_bytes };
|
smp_cache_area area = { i_addr, n_bytes };
|
||||||
|
|
||||||
_SMP_Multicast_action( 0, NULL, smp_cache_inst_inv, &area );
|
_SMP_Multicast_action( NULL, smp_cache_inst_inv, &area );
|
||||||
#else
|
#else
|
||||||
_CPU_cache_invalidate_instruction_range( i_addr, n_bytes );
|
_CPU_cache_invalidate_instruction_range( i_addr, n_bytes );
|
||||||
#endif
|
#endif
|
||||||
@@ -345,7 +345,7 @@ rtems_cache_invalidate_entire_instruction( void )
|
|||||||
{
|
{
|
||||||
#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
|
#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
|
||||||
#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
|
#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
|
||||||
_SMP_Multicast_action( 0, NULL, smp_cache_inst_inv_all, NULL );
|
_SMP_Multicast_action( NULL, smp_cache_inst_inv_all, NULL );
|
||||||
#else
|
#else
|
||||||
_CPU_cache_invalidate_entire_instruction();
|
_CPU_cache_invalidate_entire_instruction();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -249,20 +249,19 @@ void _SMP_Send_message_multicast(
|
|||||||
typedef void ( *SMP_Action_handler )( void *arg );
|
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 targets The set of target processors for the action. If @c NULL,
|
||||||
* @param[in] cpus The set of target processors of the message.
|
* then the action will be performed on all online processors.
|
||||||
* @param[in] handler The multicast action handler.
|
* @param handler The multicast action handler.
|
||||||
* @param[in] arg The multicast action argument.
|
* @param arg The multicast action argument.
|
||||||
*/
|
*/
|
||||||
void _SMP_Multicast_action(
|
void _SMP_Multicast_action(
|
||||||
const size_t setsize,
|
const Processor_mask *targets,
|
||||||
const cpu_set_t *cpus,
|
SMP_Action_handler handler,
|
||||||
SMP_Action_handler handler,
|
void *arg
|
||||||
void *arg
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -89,14 +89,12 @@ _SMP_Multicasts_try_process( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _SMP_Multicast_action(
|
void _SMP_Multicast_action(
|
||||||
const size_t setsize,
|
const Processor_mask *targets,
|
||||||
const cpu_set_t *cpus,
|
SMP_Action_handler handler,
|
||||||
SMP_Action_handler handler,
|
void *arg
|
||||||
void *arg
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
SMP_Multicast_action node;
|
SMP_Multicast_action node;
|
||||||
Processor_mask targets;
|
|
||||||
ISR_lock_Context lock_context;
|
ISR_lock_Context lock_context;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
@@ -105,29 +103,21 @@ void _SMP_Multicast_action(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cpus == NULL ) {
|
if( targets == NULL ) {
|
||||||
_Processor_mask_Assign( &targets, _SMP_Get_online_processors() );
|
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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_Chain_Initialize_node( &node.Node );
|
_Chain_Initialize_node( &node.Node );
|
||||||
node.handler = handler;
|
node.handler = handler;
|
||||||
node.arg = arg;
|
node.arg = arg;
|
||||||
_Processor_mask_Assign( &node.targets, &targets );
|
_Processor_mask_Assign( &node.targets, targets );
|
||||||
_Atomic_Store_ulong( &node.done, 0, ATOMIC_ORDER_RELAXED );
|
_Atomic_Store_ulong( &node.done, 0, ATOMIC_ORDER_RELAXED );
|
||||||
|
|
||||||
_ISR_lock_ISR_disable_and_acquire( &_SMP_Multicast.Lock, &lock_context );
|
_ISR_lock_ISR_disable_and_acquire( &_SMP_Multicast.Lock, &lock_context );
|
||||||
_Chain_Prepend_unprotected( &_SMP_Multicast.Actions, &node.Node );
|
_Chain_Prepend_unprotected( &_SMP_Multicast.Actions, &node.Node );
|
||||||
_ISR_lock_Release_and_ISR_enable( &_SMP_Multicast.Lock, &lock_context );
|
_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();
|
_SMP_Multicasts_try_process();
|
||||||
|
|
||||||
while ( _Atomic_Load_ulong( &node.done, ATOMIC_ORDER_ACQUIRE ) == 0 ) {
|
while ( _Atomic_Load_ulong( &node.done, ATOMIC_ORDER_ACQUIRE ) == 0 ) {
|
||||||
|
|||||||
@@ -314,6 +314,17 @@ smpmrsp01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_smpmrsp01) \
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if HAS_SMP
|
||||||
|
if TEST_smpmulticast01
|
||||||
|
smp_tests += smpmulticast01
|
||||||
|
smp_screens += smpmulticast01/smpmulticast01.scn
|
||||||
|
smp_docs += smpmulticast01/smpmulticast01.doc
|
||||||
|
smpmulticast01_SOURCES = smpmulticast01/init.c
|
||||||
|
smpmulticast01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_smpmulticast01) \
|
||||||
|
$(support_includes)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
if HAS_SMP
|
if HAS_SMP
|
||||||
if TEST_smpmutex01
|
if TEST_smpmutex01
|
||||||
smp_tests += smpmutex01
|
smp_tests += smpmutex01
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ RTEMS_TEST_CHECK([smplock01])
|
|||||||
RTEMS_TEST_CHECK([smpmigration01])
|
RTEMS_TEST_CHECK([smpmigration01])
|
||||||
RTEMS_TEST_CHECK([smpmigration02])
|
RTEMS_TEST_CHECK([smpmigration02])
|
||||||
RTEMS_TEST_CHECK([smpmrsp01])
|
RTEMS_TEST_CHECK([smpmrsp01])
|
||||||
|
RTEMS_TEST_CHECK([smpmulticast01])
|
||||||
RTEMS_TEST_CHECK([smpmutex01])
|
RTEMS_TEST_CHECK([smpmutex01])
|
||||||
RTEMS_TEST_CHECK([smpmutex02])
|
RTEMS_TEST_CHECK([smpmutex02])
|
||||||
RTEMS_TEST_CHECK([smpopenmp01])
|
RTEMS_TEST_CHECK([smpopenmp01])
|
||||||
|
|||||||
@@ -50,23 +50,14 @@ static void test_action( void *arg )
|
|||||||
ctx.count[rtems_scheduler_get_processor()]++;
|
ctx.count[rtems_scheduler_get_processor()]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void ( *test_case )(
|
typedef void ( *test_case )( void );
|
||||||
size_t set_size,
|
|
||||||
const cpu_set_t *cpu_set
|
|
||||||
);
|
|
||||||
|
|
||||||
static void test_cache_invalidate_entire_instruction(
|
static void test_cache_invalidate_entire_instruction( void )
|
||||||
size_t set_size,
|
|
||||||
const cpu_set_t *cpu_set
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
rtems_cache_invalidate_entire_instruction();
|
rtems_cache_invalidate_entire_instruction();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_cache_invalidate_multiple_instruction_lines(
|
static void test_cache_invalidate_multiple_instruction_lines( void )
|
||||||
size_t set_size,
|
|
||||||
const cpu_set_t *cpu_set
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
uint32_t self = rtems_scheduler_get_processor();
|
uint32_t self = rtems_scheduler_get_processor();
|
||||||
|
|
||||||
@@ -94,12 +85,9 @@ static void broadcast_test_init( void )
|
|||||||
ctx.count[rtems_scheduler_get_processor()] = 0;
|
ctx.count[rtems_scheduler_get_processor()] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void broadcast_test_body(
|
static void broadcast_test_body( void )
|
||||||
size_t set_size,
|
|
||||||
const cpu_set_t *cpu_set
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
_SMP_Multicast_action( set_size, cpu_set, test_action, &ctx );
|
_SMP_Multicast_action( NULL, test_action, &ctx );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void broadcast_test_fini( void )
|
static void broadcast_test_fini( void )
|
||||||
@@ -116,8 +104,7 @@ static test_case test_cases[] = {
|
|||||||
broadcast_test_body
|
broadcast_test_body
|
||||||
};
|
};
|
||||||
|
|
||||||
static void call_tests( size_t set_size,
|
static void call_tests( SMP_barrier_State *bs )
|
||||||
const cpu_set_t *cpu_set, SMP_barrier_State *bs )
|
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@@ -125,15 +112,14 @@ static void call_tests( size_t set_size,
|
|||||||
|
|
||||||
for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
|
for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
|
||||||
barrier( bs );
|
barrier( bs );
|
||||||
( *test_cases[ i ] )( set_size, cpu_set );
|
( *test_cases[ i ] )();
|
||||||
barrier( bs );
|
barrier( bs );
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcast_test_fini();
|
broadcast_test_fini();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void call_tests_isr_disabled( size_t set_size,
|
static void call_tests_isr_disabled( SMP_barrier_State *bs )
|
||||||
const cpu_set_t *cpu_set, SMP_barrier_State *bs )
|
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@@ -144,7 +130,7 @@ static void call_tests_isr_disabled( size_t set_size,
|
|||||||
|
|
||||||
_ISR_Local_disable( isr_level );
|
_ISR_Local_disable( isr_level );
|
||||||
barrier( bs );
|
barrier( bs );
|
||||||
( *test_cases[ i ] )( set_size, cpu_set );
|
( *test_cases[ i ] )();
|
||||||
_ISR_Local_enable( isr_level );
|
_ISR_Local_enable( isr_level );
|
||||||
barrier( bs );
|
barrier( bs );
|
||||||
}
|
}
|
||||||
@@ -152,8 +138,7 @@ static void call_tests_isr_disabled( size_t set_size,
|
|||||||
broadcast_test_fini();
|
broadcast_test_fini();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void call_tests_with_thread_dispatch_disabled( size_t set_size,
|
static void call_tests_with_thread_dispatch_disabled( SMP_barrier_State *bs )
|
||||||
const cpu_set_t *cpu_set, SMP_barrier_State *bs )
|
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@@ -164,7 +149,7 @@ static void call_tests_with_thread_dispatch_disabled( size_t set_size,
|
|||||||
|
|
||||||
cpu_self = _Thread_Dispatch_disable();
|
cpu_self = _Thread_Dispatch_disable();
|
||||||
barrier( bs );
|
barrier( bs );
|
||||||
( *test_cases[ i ] )( set_size, cpu_set );
|
( *test_cases[ i ] )();
|
||||||
barrier( bs );
|
barrier( bs );
|
||||||
_Thread_Dispatch_enable( cpu_self );
|
_Thread_Dispatch_enable( cpu_self );
|
||||||
}
|
}
|
||||||
@@ -180,32 +165,29 @@ static void cmlog( const char* str )
|
|||||||
|
|
||||||
static void all_tests( void )
|
static void all_tests( void )
|
||||||
{
|
{
|
||||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
|
||||||
size_t set_size = CPU_ALLOC_SIZE( cpu_count );
|
|
||||||
cpu_set_t *cpu_set = CPU_ALLOC( cpu_count );
|
|
||||||
SMP_barrier_State bs = SMP_BARRIER_STATE_INITIALIZER;
|
SMP_barrier_State bs = SMP_BARRIER_STATE_INITIALIZER;
|
||||||
|
|
||||||
/* Send message to all available CPUs */
|
|
||||||
CPU_FILL_S( set_size, cpu_set );
|
|
||||||
|
|
||||||
/* Call test cases */
|
/* Call test cases */
|
||||||
cmlog( "Calling test cases. " );
|
cmlog( "Calling test cases. " );
|
||||||
call_tests( set_size, cpu_set, &bs );
|
call_tests( &bs );
|
||||||
cmlog( "Done!\n");
|
cmlog( "Done!\n");
|
||||||
|
|
||||||
/* Call test cases with ISR disabled */
|
/* Call test cases with ISR disabled */
|
||||||
cmlog( "Calling test cases with ISR disabled. " );
|
cmlog( "Calling test cases with ISR disabled. " );
|
||||||
call_tests_isr_disabled( set_size, cpu_set, &bs );
|
call_tests_isr_disabled( &bs );
|
||||||
cmlog( "Done!\n" );
|
cmlog( "Done!\n" );
|
||||||
|
|
||||||
/* Call test cases with thread dispatch disabled */
|
/* Call test cases with thread dispatch disabled */
|
||||||
cmlog( "Calling test cases with thread_dispatch_disabled. ");
|
cmlog( "Calling test cases with thread_dispatch_disabled. ");
|
||||||
call_tests_with_thread_dispatch_disabled( set_size, cpu_set, &bs );
|
call_tests_with_thread_dispatch_disabled( &bs );
|
||||||
cmlog( "Done!\n");
|
cmlog( "Done!\n");
|
||||||
|
|
||||||
/* Done. Free up memory. */
|
/* Done. Free up memory. */
|
||||||
_SMP_barrier_Wait( &ctx.barrier, &bs, cpu_count);
|
_SMP_barrier_Wait(
|
||||||
CPU_FREE( cpu_set );
|
&ctx.barrier,
|
||||||
|
&bs,
|
||||||
|
rtems_scheduler_get_processor_maximum()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void worker_task(rtems_task_argument arg)
|
static void worker_task(rtems_task_argument arg)
|
||||||
|
|||||||
288
testsuites/smptests/smpmulticast01/init.c
Normal file
288
testsuites/smptests/smpmulticast01/init.c
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 embedded brains GmbH
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtems/score/smpimpl.h>
|
||||||
|
#include <rtems/score/atomic.h>
|
||||||
|
#include <rtems/score/threaddispatch.h>
|
||||||
|
#include <rtems/sysinit.h>
|
||||||
|
#include <rtems.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <t.h>
|
||||||
|
#include <tmacros.h>
|
||||||
|
|
||||||
|
#define CPU_COUNT 32
|
||||||
|
|
||||||
|
const char rtems_test_name[] = "SMPMULTICAST 1";
|
||||||
|
|
||||||
|
static const T_config config = {
|
||||||
|
.name = "SMPMultiCast",
|
||||||
|
.putchar = T_putchar_default,
|
||||||
|
.verbosity = T_VERBOSE,
|
||||||
|
.now = T_now
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Atomic_Uint id[CPU_COUNT];
|
||||||
|
} test_context;
|
||||||
|
|
||||||
|
static test_context test_instance;
|
||||||
|
|
||||||
|
static void multicast_action_irq_disabled(
|
||||||
|
const Processor_mask *targets,
|
||||||
|
SMP_Action_handler handler,
|
||||||
|
void *arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_interrupt_level level;
|
||||||
|
|
||||||
|
rtems_interrupt_local_disable(level);
|
||||||
|
_SMP_Multicast_action(targets, handler, arg);
|
||||||
|
rtems_interrupt_local_enable(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void multicast_action_dispatch_disabled(
|
||||||
|
const Processor_mask *targets,
|
||||||
|
SMP_Action_handler handler,
|
||||||
|
void *arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Per_CPU_Control *cpu_self;
|
||||||
|
|
||||||
|
cpu_self = _Thread_Dispatch_disable();
|
||||||
|
_SMP_Multicast_action(targets, handler, arg);
|
||||||
|
_Thread_Dispatch_enable(cpu_self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void action(void *arg)
|
||||||
|
{
|
||||||
|
test_context *ctx;
|
||||||
|
uint32_t self;
|
||||||
|
unsigned expected;
|
||||||
|
bool success;
|
||||||
|
|
||||||
|
ctx = arg;
|
||||||
|
self = rtems_scheduler_get_processor();
|
||||||
|
expected = 0;
|
||||||
|
success = _Atomic_Compare_exchange_uint(
|
||||||
|
&ctx->id[self],
|
||||||
|
&expected,
|
||||||
|
self + 1,
|
||||||
|
ATOMIC_ORDER_RELAXED,
|
||||||
|
ATOMIC_ORDER_RELAXED
|
||||||
|
);
|
||||||
|
T_quiet_true(success, "set CPU identifier failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_unicast(
|
||||||
|
test_context *ctx,
|
||||||
|
void (*multicast_action)(const Processor_mask *, SMP_Action_handler, void *),
|
||||||
|
bool before_multitasking
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint32_t step;
|
||||||
|
uint32_t i;
|
||||||
|
uint32_t n;
|
||||||
|
uint32_t self;
|
||||||
|
|
||||||
|
T_plan(1);
|
||||||
|
step = 0;
|
||||||
|
self = rtems_scheduler_get_processor();
|
||||||
|
n = rtems_scheduler_get_processor_maximum();
|
||||||
|
|
||||||
|
for (i = 0; i < n; ++i) {
|
||||||
|
Processor_mask cpus;
|
||||||
|
uint32_t j;
|
||||||
|
|
||||||
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
|
|
||||||
|
_Processor_mask_Zero(&cpus);
|
||||||
|
_Processor_mask_Set(&cpus, i);
|
||||||
|
(*multicast_action)(&cpus, action, ctx);
|
||||||
|
|
||||||
|
for (j = 0; j < n; ++j) {
|
||||||
|
unsigned id;
|
||||||
|
|
||||||
|
++step;
|
||||||
|
id = _Atomic_Load_uint(&ctx->id[j], ATOMIC_ORDER_RELAXED);
|
||||||
|
|
||||||
|
if (before_multitasking) {
|
||||||
|
if (j == self) {
|
||||||
|
T_quiet_eq_uint(j + 1, id);
|
||||||
|
} else {
|
||||||
|
T_quiet_eq_uint(0, id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (j == i) {
|
||||||
|
T_quiet_eq_uint(j + 1, id);
|
||||||
|
} else {
|
||||||
|
T_quiet_eq_uint(0, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
T_step_eq_u32(0, step, n * n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_broadcast(
|
||||||
|
test_context *ctx,
|
||||||
|
void (*multicast_action)(const Processor_mask *, SMP_Action_handler, void *),
|
||||||
|
bool before_multitasking
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint32_t step;
|
||||||
|
uint32_t i;
|
||||||
|
uint32_t n;
|
||||||
|
uint32_t self;
|
||||||
|
|
||||||
|
T_plan(1);
|
||||||
|
step = 0;
|
||||||
|
self = rtems_scheduler_get_processor();
|
||||||
|
n = rtems_scheduler_get_processor_maximum();
|
||||||
|
|
||||||
|
for (i = 0; i < n; ++i) {
|
||||||
|
uint32_t j;
|
||||||
|
|
||||||
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
|
|
||||||
|
(*multicast_action)(NULL, action, ctx);
|
||||||
|
|
||||||
|
for (j = 0; j < n; ++j) {
|
||||||
|
unsigned id;
|
||||||
|
|
||||||
|
++step;
|
||||||
|
id = _Atomic_Load_uint(&ctx->id[j], ATOMIC_ORDER_RELAXED);
|
||||||
|
|
||||||
|
if (before_multitasking) {
|
||||||
|
if (j == self) {
|
||||||
|
T_quiet_eq_uint(j + 1, id);
|
||||||
|
} else {
|
||||||
|
T_quiet_eq_uint(0, id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
T_quiet_eq_uint(j + 1, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
T_step_eq_u32(0, step, n * n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_before_multitasking(void)
|
||||||
|
{
|
||||||
|
test_context *ctx;
|
||||||
|
|
||||||
|
ctx = &test_instance;
|
||||||
|
|
||||||
|
T_case_begin("UnicastBeforeMultitasking", NULL);
|
||||||
|
test_unicast(ctx, _SMP_Multicast_action, true);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("UnicastBeforeMultitaskingIRQDisabled", NULL);
|
||||||
|
test_unicast(ctx, multicast_action_irq_disabled, true);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("UnicastBeforeMultitaskingDispatchDisabled", NULL);
|
||||||
|
test_unicast(ctx, multicast_action_dispatch_disabled, true);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("BroadcastBeforeMultitasking", NULL);
|
||||||
|
test_broadcast(ctx, _SMP_Multicast_action, true);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("BroadcastBeforeMultitaskingIRQDisabled", NULL);
|
||||||
|
test_broadcast(ctx, multicast_action_irq_disabled, true);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("BroadcastBeforeMultitaskingDispatchDisabled", NULL);
|
||||||
|
test_broadcast(ctx, multicast_action_dispatch_disabled, true);
|
||||||
|
T_case_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void after_drivers(void)
|
||||||
|
{
|
||||||
|
TEST_BEGIN();
|
||||||
|
T_run_initialize(&config);
|
||||||
|
test_before_multitasking();
|
||||||
|
}
|
||||||
|
|
||||||
|
RTEMS_SYSINIT_ITEM(
|
||||||
|
after_drivers,
|
||||||
|
RTEMS_SYSINIT_DEVICE_DRIVERS,
|
||||||
|
RTEMS_SYSINIT_ORDER_LAST
|
||||||
|
);
|
||||||
|
|
||||||
|
static void Init(rtems_task_argument arg)
|
||||||
|
{
|
||||||
|
test_context *ctx;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
ctx = &test_instance;
|
||||||
|
|
||||||
|
T_case_begin("UnicastDuringMultitasking", NULL);
|
||||||
|
test_unicast(ctx, _SMP_Multicast_action, false);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("UnicastDuringMultitaskingIRQDisabled", NULL);
|
||||||
|
test_unicast(ctx, multicast_action_irq_disabled, false);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("UnicastDuringMultitaskingDispatchDisabled", NULL);
|
||||||
|
test_unicast(ctx, multicast_action_dispatch_disabled, false);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("BroadcastDuringMultitasking", NULL);
|
||||||
|
test_broadcast(ctx, _SMP_Multicast_action, false);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("BroadcastDuringMultitaskingIRQDisabled", NULL);
|
||||||
|
test_broadcast(ctx, multicast_action_irq_disabled, false);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
T_case_begin("BroadcastDuringMultitaskingDispatchDisabled", NULL);
|
||||||
|
test_broadcast(ctx, multicast_action_dispatch_disabled, false);
|
||||||
|
T_case_end();
|
||||||
|
|
||||||
|
ok = T_run_finalize();
|
||||||
|
rtems_test_assert(ok);
|
||||||
|
TEST_END();
|
||||||
|
rtems_test_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||||
|
|
||||||
|
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||||
|
|
||||||
|
#define CONFIGURE_MAXIMUM_PROCESSORS CPU_COUNT
|
||||||
|
|
||||||
|
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||||
|
|
||||||
|
#define CONFIGURE_INIT
|
||||||
|
|
||||||
|
#include <rtems/confdefs.h>
|
||||||
12
testsuites/smptests/smpmulticast01/smpmulticast01.doc
Normal file
12
testsuites/smptests/smpmulticast01/smpmulticast01.doc
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
This file describes the directives and concepts tested by this test set.
|
||||||
|
|
||||||
|
test set name: smpmulticast01
|
||||||
|
|
||||||
|
directives:
|
||||||
|
|
||||||
|
- _SMP_Multicast_action()
|
||||||
|
|
||||||
|
concepts:
|
||||||
|
|
||||||
|
- Ensure that _SMP_Multicast_action() works before multitasking.
|
||||||
|
- Ensure that _SMP_Multicast_action() works during multitasking.
|
||||||
54
testsuites/smptests/smpmulticast01/smpmulticast01.scn
Normal file
54
testsuites/smptests/smpmulticast01/smpmulticast01.scn
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
*** BEGIN OF TEST SMPMULTICAST 1 ***
|
||||||
|
*** TEST VERSION: 5.0.0.c44199ccea624f31b1116fa2e47d547944e90909-modified
|
||||||
|
*** TEST STATE: EXPECTED-PASS
|
||||||
|
*** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP
|
||||||
|
*** TEST TOOLS: 7.4.0 20181206 (RTEMS 5, RSB e0aec65182449a4e22b820e773087636edaf5b32, Newlib 1d35a003f)
|
||||||
|
A:SMPMultiCast
|
||||||
|
S:Platform:RTEMS
|
||||||
|
S:Compiler:7.4.0 20181206 (RTEMS 5, RSB e0aec65182449a4e22b820e773087636edaf5b32, Newlib 1d35a003f)
|
||||||
|
S:Version:5.0.0.c44199ccea624f31b1116fa2e47d547944e90909
|
||||||
|
S:BSP:qoriq_e6500_32
|
||||||
|
S:RTEMS_DEBUG:0
|
||||||
|
S:RTEMS_MULTIPROCESSING:0
|
||||||
|
S:RTEMS_POSIX_API:1
|
||||||
|
S:RTEMS_PROFILING:0
|
||||||
|
S:RTEMS_SMP:1
|
||||||
|
B:UnicastBeforeMultitasking
|
||||||
|
P:0:0:IDLE:init.c:150
|
||||||
|
E:UnicastBeforeMultitasking:N:1:F:0:D:0.001999
|
||||||
|
B:UnicastBeforeMultitaskingIRQDisabled
|
||||||
|
P:0:0:IDLE:init.c:150
|
||||||
|
E:UnicastBeforeMultitaskingIRQDisabled:N:1:F:0:D:0.001999
|
||||||
|
B:UnicastBeforeMultitaskingDispatchDisabled
|
||||||
|
P:0:0:IDLE:init.c:150
|
||||||
|
E:UnicastBeforeMultitaskingDispatchDisabled:N:1:F:0:D:0.001999
|
||||||
|
B:BroadcastBeforeMultitasking
|
||||||
|
P:0:0:IDLE:init.c:194
|
||||||
|
E:BroadcastBeforeMultitasking:N:1:F:0:D:0.001999
|
||||||
|
B:BroadcastBeforeMultitaskingIRQDisabled
|
||||||
|
P:0:0:IDLE:init.c:194
|
||||||
|
E:BroadcastBeforeMultitaskingIRQDisabled:N:1:F:0:D:0.001999
|
||||||
|
B:BroadcastBeforeMultitaskingDispatchDisabled
|
||||||
|
P:0:0:IDLE:init.c:194
|
||||||
|
E:BroadcastBeforeMultitaskingDispatchDisabled:N:1:F:0:D:0.001999
|
||||||
|
B:UnicastDuringMultitasking
|
||||||
|
P:0:23:UI1:init.c:150
|
||||||
|
E:UnicastDuringMultitasking:N:1:F:0:D:0.001999
|
||||||
|
B:UnicastDuringMultitaskingIRQDisabled
|
||||||
|
P:0:23:UI1:init.c:150
|
||||||
|
E:UnicastDuringMultitaskingIRQDisabled:N:1:F:0:D:0.002000
|
||||||
|
B:UnicastDuringMultitaskingDispatchDisabled
|
||||||
|
P:0:23:UI1:init.c:150
|
||||||
|
E:UnicastDuringMultitaskingDispatchDisabled:N:1:F:0:D:0.002000
|
||||||
|
B:BroadcastDuringMultitasking
|
||||||
|
P:0:23:UI1:init.c:194
|
||||||
|
E:BroadcastDuringMultitasking:N:1:F:0:D:0.002134
|
||||||
|
B:BroadcastDuringMultitaskingIRQDisabled
|
||||||
|
P:0:23:UI1:init.c:194
|
||||||
|
E:BroadcastDuringMultitaskingIRQDisabled:N:1:F:0:D:0.002165
|
||||||
|
B:BroadcastDuringMultitaskingDispatchDisabled
|
||||||
|
P:0:23:UI1:init.c:194
|
||||||
|
E:BroadcastDuringMultitaskingDispatchDisabled:N:1:F:0:D:0.002130
|
||||||
|
Z:SMPMultiCast:C:12:N:12:F:0:D:0.125615
|
||||||
|
|
||||||
|
*** END OF TEST SMPMULTICAST 1 ***
|
||||||
Reference in New Issue
Block a user