mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 19:35:42 +08:00
testsuites/smptests: reformat with clang-format
Updates #3860. Updates #5358.
This commit is contained in:
committed by
Kinsey Moore
parent
57ea3fe79f
commit
f5d93a7421
@@ -37,31 +37,30 @@
|
||||
|
||||
const char rtems_test_name[] = "SMP 1";
|
||||
|
||||
void Loop() {
|
||||
void Loop()
|
||||
{
|
||||
volatile int i;
|
||||
|
||||
for (i=0; i<300000; i++);
|
||||
for ( i = 0; i < 300000; i++ );
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Init( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
uint32_t i;
|
||||
char ch;
|
||||
uint32_t cpu_self;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
bool allDone;
|
||||
uint32_t i;
|
||||
char ch;
|
||||
uint32_t cpu_self;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
bool allDone;
|
||||
|
||||
cpu_self = rtems_scheduler_get_processor();
|
||||
|
||||
/* XXX - Delay a bit to allow debug messages from
|
||||
* startup to print. This may need to go away when
|
||||
* debug messages go away.
|
||||
*/
|
||||
*/
|
||||
Loop();
|
||||
|
||||
TEST_BEGIN();
|
||||
@@ -69,12 +68,12 @@ rtems_task Init(
|
||||
locked_print_initialize();
|
||||
|
||||
/* Initialize the TaskRan array */
|
||||
for ( i=0; i<rtems_scheduler_get_processor_maximum() ; i++ ) {
|
||||
TaskRan[i] = false;
|
||||
for ( i = 0; i < rtems_scheduler_get_processor_maximum(); i++ ) {
|
||||
TaskRan[ i ] = false;
|
||||
}
|
||||
|
||||
/* Create and start tasks for each processor */
|
||||
for ( i=0; i< rtems_scheduler_get_processor_maximum() ; i++ ) {
|
||||
for ( i = 0; i < rtems_scheduler_get_processor_maximum(); i++ ) {
|
||||
if ( i != cpu_self ) {
|
||||
ch = '0' + i;
|
||||
|
||||
@@ -88,25 +87,25 @@ rtems_task Init(
|
||||
);
|
||||
directive_failed( status, "task create" );
|
||||
|
||||
locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_self, ch);
|
||||
status = rtems_task_start( id, Test_task, i+1 );
|
||||
locked_printf( " CPU %" PRIu32 " start task TA%c\n", cpu_self, ch );
|
||||
status = rtems_task_start( id, Test_task, i + 1 );
|
||||
directive_failed( status, "task start" );
|
||||
|
||||
Loop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Wait on the all tasks to run */
|
||||
while (1) {
|
||||
while ( 1 ) {
|
||||
allDone = true;
|
||||
for ( i=0; i<rtems_scheduler_get_processor_maximum() ; i++ ) {
|
||||
if ( i != cpu_self && TaskRan[i] == false)
|
||||
for ( i = 0; i < rtems_scheduler_get_processor_maximum(); i++ ) {
|
||||
if ( i != cpu_self && TaskRan[ i ] == false ) {
|
||||
allDone = false;
|
||||
}
|
||||
}
|
||||
if (allDone) {
|
||||
if ( allDone ) {
|
||||
TEST_END();
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,23 +31,18 @@
|
||||
|
||||
/* functions */
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Init( rtems_task_argument argument );
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Test_task( rtems_task_argument argument );
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS \
|
||||
(1 + CONFIGURE_MAXIMUM_PROCESSORS)
|
||||
#define CONFIGURE_MAXIMUM_TASKS ( 1 + CONFIGURE_MAXIMUM_PROCESSORS )
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
@@ -34,33 +34,30 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument task_index
|
||||
)
|
||||
rtems_task Test_task( rtems_task_argument task_index )
|
||||
{
|
||||
(void) task_index;
|
||||
|
||||
uint32_t cpu_num;
|
||||
char name[5];
|
||||
char *p;
|
||||
uint32_t cpu_num;
|
||||
char name[ 5 ];
|
||||
char *p;
|
||||
|
||||
/* Get the task name */
|
||||
p = rtems_object_get_name( RTEMS_SELF, 5, name );
|
||||
rtems_test_assert( p != NULL );
|
||||
|
||||
/* Get the CPU Number */
|
||||
/* Get the CPU Number */
|
||||
cpu_num = rtems_scheduler_get_processor();
|
||||
|
||||
/* Print that the task is up and running. */
|
||||
Loop();
|
||||
locked_printf(" CPU %" PRIu32 " running Task %s\n", cpu_num, name);
|
||||
locked_printf( " CPU %" PRIu32 " running Task %s\n", cpu_num, name );
|
||||
|
||||
/* Set the flag that the task is up and running */
|
||||
TaskRan[cpu_num] = true;
|
||||
|
||||
TaskRan[ cpu_num ] = true;
|
||||
|
||||
/* Drop into a loop which will keep this task on
|
||||
* running on the cpu.
|
||||
*/
|
||||
while(1);
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
@@ -38,15 +38,13 @@
|
||||
|
||||
const char rtems_test_name[] = "SMP 2";
|
||||
|
||||
static void success(void)
|
||||
static void success( void )
|
||||
{
|
||||
TEST_END();
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Init( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
@@ -55,7 +53,7 @@ rtems_task Init(
|
||||
uint32_t cpu_num;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
char str[80];
|
||||
char str[ 80 ];
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
@@ -67,21 +65,19 @@ rtems_task Init(
|
||||
|
||||
/* Create/verify synchronisation semaphore */
|
||||
status = rtems_semaphore_create(
|
||||
rtems_build_name ('S', 'E', 'M', '1'),
|
||||
1,
|
||||
RTEMS_LOCAL |
|
||||
RTEMS_SIMPLE_BINARY_SEMAPHORE |
|
||||
RTEMS_PRIORITY,
|
||||
rtems_build_name( 'S', 'E', 'M', '1' ),
|
||||
1,
|
||||
&Semaphore);
|
||||
RTEMS_LOCAL | RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY,
|
||||
1,
|
||||
&Semaphore
|
||||
);
|
||||
directive_failed( status, "rtems_semaphore_create" );
|
||||
|
||||
/* Lock semaphore */
|
||||
status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0);
|
||||
directive_failed( status,"rtems_semaphore_obtain of SEM1\n");
|
||||
|
||||
for ( i=1; i < rtems_scheduler_get_processor_maximum(); i++ ){
|
||||
status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0 );
|
||||
directive_failed( status, "rtems_semaphore_obtain of SEM1\n" );
|
||||
|
||||
for ( i = 1; i < rtems_scheduler_get_processor_maximum(); i++ ) {
|
||||
/* Create and start tasks for each CPU */
|
||||
ch = '0' + i;
|
||||
|
||||
@@ -95,8 +91,8 @@ rtems_task Init(
|
||||
);
|
||||
|
||||
cpu_num = rtems_scheduler_get_processor();
|
||||
locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);
|
||||
status = rtems_task_start( id, Test_task, i+1 );
|
||||
locked_printf( " CPU %" PRIu32 " start task TA%c\n", cpu_num, ch );
|
||||
status = rtems_task_start( id, Test_task, i + 1 );
|
||||
directive_failed( status, str );
|
||||
}
|
||||
|
||||
@@ -104,27 +100,25 @@ rtems_task Init(
|
||||
* Release the semaphore, allowing the blocked tasks to start.
|
||||
*/
|
||||
status = rtems_semaphore_release( Semaphore );
|
||||
directive_failed( status,"rtems_semaphore_release of SEM1\n");
|
||||
|
||||
directive_failed( status, "rtems_semaphore_release of SEM1\n" );
|
||||
|
||||
/*
|
||||
* Wait for log full. print the log and end the program.
|
||||
*/
|
||||
while (Log_index < LOG_SIZE)
|
||||
;
|
||||
|
||||
for (i=0; i< LOG_SIZE; i++) {
|
||||
if ( Log[i].IsLocked ) {
|
||||
*/
|
||||
while ( Log_index < LOG_SIZE );
|
||||
|
||||
for ( i = 0; i < LOG_SIZE; i++ ) {
|
||||
if ( Log[ i ].IsLocked ) {
|
||||
locked_printf(
|
||||
" CPU %d Task TA%" PRIu32 " Obtain\n",
|
||||
Log[i].cpu_num,
|
||||
Log[i].task_index
|
||||
" CPU %d Task TA%" PRIu32 " Obtain\n",
|
||||
Log[ i ].cpu_num,
|
||||
Log[ i ].task_index
|
||||
);
|
||||
} else {
|
||||
locked_printf(
|
||||
" CPU %d Task TA%" PRIu32 " Release\n",
|
||||
Log[i].cpu_num,
|
||||
Log[i].task_index
|
||||
" CPU %d Task TA%" PRIu32 " Release\n",
|
||||
Log[ i ].cpu_num,
|
||||
Log[ i ].task_index
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,37 +31,31 @@
|
||||
|
||||
/* functions */
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Init( rtems_task_argument argument );
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Test_task( rtems_task_argument argument );
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS \
|
||||
(1 + CONFIGURE_MAXIMUM_PROCESSORS)
|
||||
#define CONFIGURE_MAXIMUM_TASKS ( 1 + CONFIGURE_MAXIMUM_PROCESSORS )
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE \
|
||||
(3 * CONFIGURE_MINIMUM_TASK_STACK_SIZE)
|
||||
( 3 * CONFIGURE_MINIMUM_TASK_STACK_SIZE )
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
|
||||
/* global variables */
|
||||
|
||||
/*
|
||||
@@ -74,11 +68,11 @@ typedef struct {
|
||||
uint32_t task_index;
|
||||
} Log_t;
|
||||
|
||||
#define LOG_SIZE 20
|
||||
#define LOG_SIZE 20
|
||||
|
||||
TEST_EXTERN rtems_id Semaphore; /* synchronisation semaphore */
|
||||
TEST_EXTERN Log_t Log[LOG_SIZE]; /* A log of locks/unlocks */
|
||||
TEST_EXTERN volatile uint32_t Log_index; /* Index into log */
|
||||
TEST_EXTERN rtems_id Semaphore; /* synchronisation semaphore */
|
||||
TEST_EXTERN Log_t Log[ LOG_SIZE ]; /* A log of locks/unlocks */
|
||||
TEST_EXTERN volatile uint32_t Log_index; /* Index into log */
|
||||
|
||||
/*
|
||||
* Handy macros and static inline functions
|
||||
|
||||
@@ -33,22 +33,21 @@
|
||||
#include "system.h"
|
||||
|
||||
static void LogSemaphore(
|
||||
bool obtained,
|
||||
uint32_t cpu_num,
|
||||
uint32_t task_index
|
||||
){
|
||||
if (Log_index < LOG_SIZE) {
|
||||
bool obtained,
|
||||
uint32_t cpu_num,
|
||||
uint32_t task_index
|
||||
)
|
||||
{
|
||||
if ( Log_index < LOG_SIZE ) {
|
||||
/* Log the information */
|
||||
Log[ Log_index ].IsLocked = obtained;
|
||||
Log[ Log_index ].cpu_num = cpu_num;
|
||||
Log[ Log_index ].IsLocked = obtained;
|
||||
Log[ Log_index ].cpu_num = cpu_num;
|
||||
Log[ Log_index ].task_index = task_index;
|
||||
Log_index++;
|
||||
}
|
||||
}
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument task_index
|
||||
)
|
||||
rtems_task Test_task( rtems_task_argument task_index )
|
||||
{
|
||||
uint32_t cpu_num;
|
||||
rtems_status_code sc;
|
||||
@@ -56,15 +55,14 @@ rtems_task Test_task(
|
||||
cpu_num = rtems_scheduler_get_processor();
|
||||
|
||||
do {
|
||||
|
||||
/* Poll to obtain the synchronization semaphore */
|
||||
do {
|
||||
sc = rtems_semaphore_obtain( Semaphore, RTEMS_NO_WAIT, 0 );
|
||||
} while (sc != RTEMS_SUCCESSFUL );
|
||||
} while ( sc != RTEMS_SUCCESSFUL );
|
||||
|
||||
LogSemaphore( true, cpu_num, task_index );
|
||||
LogSemaphore( false, cpu_num, task_index );
|
||||
|
||||
LogSemaphore(true, cpu_num, task_index);
|
||||
LogSemaphore(false, cpu_num, task_index);
|
||||
|
||||
rtems_semaphore_release( Semaphore );
|
||||
} while(1);
|
||||
} while ( 1 );
|
||||
}
|
||||
|
||||
@@ -38,32 +38,29 @@
|
||||
|
||||
const char rtems_test_name[] = "SMP 3";
|
||||
|
||||
static void success(void)
|
||||
static void success( void )
|
||||
{
|
||||
TEST_END();
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
void Loop() {
|
||||
void Loop()
|
||||
{
|
||||
volatile int i;
|
||||
|
||||
for (i=0; i<300000; i++);
|
||||
for ( i = 0; i < 300000; i++ );
|
||||
}
|
||||
|
||||
void PrintTaskInfo(
|
||||
const char *task_name
|
||||
)
|
||||
void PrintTaskInfo( const char *task_name )
|
||||
{
|
||||
uint32_t cpu_num;
|
||||
|
||||
cpu_num = rtems_scheduler_get_processor();
|
||||
|
||||
locked_printf(" CPU %" PRIu32 " running task %s\n", cpu_num, task_name );
|
||||
locked_printf( " CPU %" PRIu32 " running task %s\n", cpu_num, task_name );
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Init( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
@@ -85,22 +82,21 @@ rtems_task Init(
|
||||
}
|
||||
|
||||
/* Initialize the TaskRan array */
|
||||
TaskRan[0] = true;
|
||||
for ( i=1; i<cpu_max ; i++ ) {
|
||||
TaskRan[i] = false;
|
||||
TaskRan[ 0 ] = true;
|
||||
for ( i = 1; i < cpu_max; i++ ) {
|
||||
TaskRan[ i ] = false;
|
||||
}
|
||||
|
||||
/* Show that the init task is running on this cpu */
|
||||
PrintTaskInfo( "Init" );
|
||||
|
||||
/* for each remaining cpu create and start a task */
|
||||
for ( i=1; i < cpu_max; i++ ){
|
||||
|
||||
for ( i = 1; i < cpu_max; i++ ) {
|
||||
ch = '0' + i;
|
||||
|
||||
status = rtems_task_create(
|
||||
rtems_build_name( 'T', 'A', ch, ' ' ),
|
||||
CONFIGURE_INIT_TASK_PRIORITY + (2*i),
|
||||
CONFIGURE_INIT_TASK_PRIORITY + ( 2 * i ),
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_PREEMPT,
|
||||
RTEMS_FLOATING_POINT,
|
||||
@@ -109,12 +105,11 @@ rtems_task Init(
|
||||
directive_failed( status, "rtems_task_create" );
|
||||
status = rtems_task_start( id, Test_task, i );
|
||||
directive_failed( status, "rtems_task_start" );
|
||||
|
||||
|
||||
/* Allow task to start before starting next task.
|
||||
* This is necessary on some simulators.
|
||||
*/
|
||||
while (TaskRan[i] == false)
|
||||
;
|
||||
*/
|
||||
while ( TaskRan[ i ] == false );
|
||||
}
|
||||
|
||||
/* Create/Start an aditional task with the highest priority */
|
||||
@@ -127,20 +122,21 @@ rtems_task Init(
|
||||
&id
|
||||
);
|
||||
directive_failed( status, "rtems_task_create" );
|
||||
status = rtems_task_start(id,Test_task,cpu_max);
|
||||
status = rtems_task_start( id, Test_task, cpu_max );
|
||||
directive_failed( status, "rtems_task_start" );
|
||||
|
||||
/* Wait on all tasks to run */
|
||||
while (1) {
|
||||
while ( 1 ) {
|
||||
TestFinished = true;
|
||||
for ( i=1; i < (cpu_max+1) ; i++ ) {
|
||||
if (TaskRan[i] == false)
|
||||
for ( i = 1; i < ( cpu_max + 1 ); i++ ) {
|
||||
if ( TaskRan[ i ] == false ) {
|
||||
TestFinished = false;
|
||||
}
|
||||
}
|
||||
if (TestFinished) {
|
||||
if ( TestFinished ) {
|
||||
success();
|
||||
}
|
||||
}
|
||||
|
||||
rtems_test_exit( 0 );
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
@@ -31,23 +31,18 @@
|
||||
|
||||
/* functions */
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Init( rtems_task_argument argument );
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Test_task( rtems_task_argument argument );
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS \
|
||||
(1 + CONFIGURE_MAXIMUM_PROCESSORS)
|
||||
#define CONFIGURE_MAXIMUM_TASKS ( 1 + CONFIGURE_MAXIMUM_PROCESSORS )
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
@@ -55,14 +50,13 @@ rtems_task Test_task(
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE \
|
||||
(3 * CONFIGURE_MINIMUM_TASK_STACK_SIZE)
|
||||
( 3 * CONFIGURE_MINIMUM_TASK_STACK_SIZE )
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 5
|
||||
#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 5
|
||||
#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
|
||||
/* global variables */
|
||||
|
||||
/*
|
||||
@@ -74,12 +68,10 @@ TEST_EXTERN volatile bool TaskRan[ CONFIGURE_MAXIMUM_PROCESSORS + 1 ];
|
||||
/*
|
||||
* Keep the names and IDs in global variables so another task can use them.
|
||||
*/
|
||||
void Loop(void);
|
||||
void PrintTaskInfo(
|
||||
const char *task_name
|
||||
);
|
||||
void Loop( void );
|
||||
void PrintTaskInfo( const char *task_name );
|
||||
|
||||
TEST_EXTERN volatile bool TestFinished;
|
||||
TEST_EXTERN volatile bool TestFinished;
|
||||
|
||||
/*
|
||||
* Handy macros and static inline functions
|
||||
|
||||
@@ -32,19 +32,16 @@
|
||||
|
||||
#include "system.h"
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument task_index
|
||||
)
|
||||
rtems_task Test_task( rtems_task_argument task_index )
|
||||
{
|
||||
char task_name[5];
|
||||
char task_name[ 5 ];
|
||||
|
||||
/* Show that this task is running on cpu X */
|
||||
sprintf( task_name, "TA%" PRIuPTR, task_index );
|
||||
PrintTaskInfo( task_name );
|
||||
|
||||
TaskRan[task_index] = true;
|
||||
TaskRan[ task_index ] = true;
|
||||
|
||||
/* Wait for the test to end without giving up this processor */
|
||||
while(1)
|
||||
;
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
@@ -37,46 +37,40 @@ const char rtems_test_name[] = "SMP 5";
|
||||
|
||||
static volatile bool init_task_done;
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Init( rtems_task_argument argument );
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Test_task( rtems_task_argument argument );
|
||||
|
||||
|
||||
static void success(void)
|
||||
static void success( void )
|
||||
{
|
||||
TEST_END();
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Test_task( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
while (!init_task_done) {
|
||||
while ( !init_task_done ) {
|
||||
/* Wait */
|
||||
}
|
||||
|
||||
locked_printf( "Shut down from CPU %" PRIu32 "\n", rtems_scheduler_get_processor() );
|
||||
locked_printf(
|
||||
"Shut down from CPU %" PRIu32 "\n",
|
||||
rtems_scheduler_get_processor()
|
||||
);
|
||||
success();
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Init( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
uint32_t i;
|
||||
char ch;
|
||||
uint32_t cpu_num;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
uint32_t i;
|
||||
char ch;
|
||||
uint32_t cpu_num;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
|
||||
locked_print_initialize();
|
||||
TEST_BEGIN();
|
||||
@@ -85,7 +79,7 @@ rtems_task Init(
|
||||
success();
|
||||
}
|
||||
|
||||
for ( i=0; i<rtems_scheduler_get_processor_maximum() ; i++ ) {
|
||||
for ( i = 0; i < rtems_scheduler_get_processor_maximum(); i++ ) {
|
||||
ch = '1' + i;
|
||||
|
||||
status = rtems_task_create(
|
||||
@@ -99,16 +93,15 @@ rtems_task Init(
|
||||
directive_failed( status, "task create" );
|
||||
|
||||
cpu_num = rtems_scheduler_get_processor();
|
||||
locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);
|
||||
locked_printf( " CPU %" PRIu32 " start task TA%c\n", cpu_num, ch );
|
||||
|
||||
status = rtems_task_start( id, Test_task, i+1 );
|
||||
status = rtems_task_start( id, Test_task, i + 1 );
|
||||
directive_failed( status, "task start" );
|
||||
}
|
||||
|
||||
init_task_done = true;
|
||||
|
||||
while (1)
|
||||
;
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
@@ -116,10 +109,9 @@ rtems_task Init(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 2
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 2
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS \
|
||||
(1 + CONFIGURE_MAXIMUM_PROCESSORS)
|
||||
#define CONFIGURE_MAXIMUM_TASKS ( 1 + CONFIGURE_MAXIMUM_PROCESSORS )
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
@@ -39,46 +39,45 @@ volatile bool TaskRan = false;
|
||||
volatile bool TSRFired = false;
|
||||
rtems_id Semaphore;
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Init( rtems_task_argument argument );
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Test_task( rtems_task_argument argument );
|
||||
|
||||
static void success(void)
|
||||
static void success( void )
|
||||
{
|
||||
TEST_END( );
|
||||
TEST_END();
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Test_task( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
uint32_t cpu_num;
|
||||
rtems_status_code sc;
|
||||
char name[5];
|
||||
char name[ 5 ];
|
||||
char *p;
|
||||
|
||||
/* Get the task name */
|
||||
p = rtems_object_get_name( RTEMS_SELF, 5, name );
|
||||
rtems_test_assert( p != NULL );
|
||||
|
||||
/* Get the CPU Number */
|
||||
/* Get the CPU Number */
|
||||
cpu_num = rtems_scheduler_get_processor();
|
||||
|
||||
/* Print that the task is up and running. */
|
||||
locked_printf(" CPU %" PRIu32 " runnng Task %s and blocking\n", cpu_num, name);
|
||||
locked_printf(
|
||||
" CPU %" PRIu32 " runnng Task %s and blocking\n",
|
||||
cpu_num,
|
||||
name
|
||||
);
|
||||
|
||||
sc = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
|
||||
directive_failed( sc,"obtain in test task");
|
||||
directive_failed( sc, "obtain in test task" );
|
||||
|
||||
if ( !TSRFired )
|
||||
if ( !TSRFired ) {
|
||||
locked_printf( "*** ERROR TSR DID NOT FIRE BUT TEST TASK AWAKE***" );
|
||||
}
|
||||
|
||||
/* Print that the task is up and running. */
|
||||
locked_printf(
|
||||
@@ -92,11 +91,7 @@ rtems_task Test_task(
|
||||
rtems_task_exit();
|
||||
}
|
||||
|
||||
|
||||
static rtems_timer_service_routine TimerMethod(
|
||||
rtems_id timer,
|
||||
void *arg
|
||||
)
|
||||
static rtems_timer_service_routine TimerMethod( rtems_id timer, void *arg )
|
||||
{
|
||||
(void) timer;
|
||||
(void) arg;
|
||||
@@ -109,18 +104,16 @@ static rtems_timer_service_routine TimerMethod(
|
||||
rtems_semaphore_release( Semaphore );
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Init( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
int cpu_num;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
rtems_interval per_second;
|
||||
rtems_interval then;
|
||||
rtems_id Timer;
|
||||
int cpu_num;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
rtems_interval per_second;
|
||||
rtems_interval then;
|
||||
rtems_id Timer;
|
||||
|
||||
locked_print_initialize();
|
||||
TEST_BEGIN();
|
||||
@@ -131,19 +124,17 @@ rtems_task Init(
|
||||
|
||||
/* Create/verify semaphore */
|
||||
status = rtems_semaphore_create(
|
||||
rtems_build_name ('S', 'E', 'M', '1'),
|
||||
rtems_build_name( 'S', 'E', 'M', '1' ),
|
||||
1,
|
||||
RTEMS_LOCAL |
|
||||
RTEMS_SIMPLE_BINARY_SEMAPHORE |
|
||||
RTEMS_PRIORITY,
|
||||
RTEMS_LOCAL | RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY,
|
||||
1,
|
||||
&Semaphore
|
||||
);
|
||||
directive_failed( status, "rtems_semaphore_create" );
|
||||
|
||||
/* Lock semaphore */
|
||||
status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0);
|
||||
directive_failed( status,"rtems_semaphore_obtain of SEM1\n");
|
||||
status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0 );
|
||||
directive_failed( status, "rtems_semaphore_obtain of SEM1\n" );
|
||||
|
||||
/* Create and Start test task. */
|
||||
status = rtems_task_create(
|
||||
@@ -157,18 +148,21 @@ rtems_task Init(
|
||||
directive_failed( status, "task create" );
|
||||
|
||||
cpu_num = rtems_scheduler_get_processor();
|
||||
locked_printf(" CPU %d start task TA1\n", cpu_num );
|
||||
locked_printf( " CPU %d start task TA1\n", cpu_num );
|
||||
status = rtems_task_start( id, Test_task, 1 );
|
||||
directive_failed( status, "task start" );
|
||||
|
||||
/* Create and start TSR */
|
||||
locked_printf(" CPU %d create and start timer\n", cpu_num );
|
||||
status = rtems_timer_create( rtems_build_name( 'T', 'M', 'R', '1' ), &Timer);
|
||||
locked_printf( " CPU %d create and start timer\n", cpu_num );
|
||||
status = rtems_timer_create(
|
||||
rtems_build_name( 'T', 'M', 'R', '1' ),
|
||||
&Timer
|
||||
);
|
||||
directive_failed( status, "rtems_timer_create" );
|
||||
|
||||
per_second = rtems_clock_get_ticks_per_second();
|
||||
status = rtems_timer_fire_after( Timer, 2 * per_second, TimerMethod, NULL );
|
||||
directive_failed( status, "rtems_timer_fire_after");
|
||||
directive_failed( status, "rtems_timer_fire_after" );
|
||||
|
||||
/*
|
||||
* Wait long enough that TSR should have fired.
|
||||
@@ -176,20 +170,23 @@ rtems_task Init(
|
||||
* Spin so CPU 0 is consumed. This forces task to run on CPU 1.
|
||||
*/
|
||||
then = rtems_clock_get_ticks_since_boot() + 4 * per_second;
|
||||
while (1) {
|
||||
if ( rtems_clock_get_ticks_since_boot() > then )
|
||||
while ( 1 ) {
|
||||
if ( rtems_clock_get_ticks_since_boot() > then ) {
|
||||
break;
|
||||
if ( TSRFired && TaskRan )
|
||||
}
|
||||
if ( TSRFired && TaskRan ) {
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/* Validate the timer fired and that the task ran */
|
||||
if ( !TSRFired )
|
||||
if ( !TSRFired ) {
|
||||
locked_printf( "*** ERROR TSR DID NOT FIRE ***" );
|
||||
}
|
||||
|
||||
if ( !TaskRan ) {
|
||||
locked_printf( "*** ERROR TASK DID NOT RUN ***" );
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
/* End the program */
|
||||
@@ -201,14 +198,14 @@ rtems_task Init(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 2
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 1
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 2
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 1
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 2
|
||||
#define CONFIGURE_MAXIMUM_TASKS 2
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
|
||||
@@ -35,10 +35,7 @@
|
||||
|
||||
const char rtems_test_name[] = "SMP 8";
|
||||
|
||||
void PrintTaskInfo(
|
||||
const char *task_name,
|
||||
rtems_time_of_day *_tb
|
||||
)
|
||||
void PrintTaskInfo( const char *task_name, rtems_time_of_day *_tb )
|
||||
{
|
||||
uint32_t cpu_num;
|
||||
|
||||
@@ -47,48 +44,48 @@ void PrintTaskInfo(
|
||||
/* Print the cpu number and task name */
|
||||
locked_printf(
|
||||
" CPU %" PRIu32 " running task %s - rtems_clock_get_tod "
|
||||
"%02" PRId32 ":%02" PRId32 ":%02" PRId32 " %02" PRId32
|
||||
"/%02" PRId32 "/%04" PRId32 "\n",
|
||||
"%02" PRId32 ":%02" PRId32 ":%02" PRId32 " %02" PRId32 "/%02" PRId32
|
||||
"/%04" PRId32 "\n",
|
||||
cpu_num,
|
||||
task_name,
|
||||
_tb->hour, _tb->minute, _tb->second,
|
||||
_tb->month, _tb->day, _tb->year
|
||||
);
|
||||
_tb->hour,
|
||||
_tb->minute,
|
||||
_tb->second,
|
||||
_tb->month,
|
||||
_tb->day,
|
||||
_tb->year
|
||||
);
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Init( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
rtems_status_code status;
|
||||
rtems_time_of_day time;
|
||||
uint32_t i;
|
||||
char ch[4];
|
||||
char ch[ 4 ];
|
||||
rtems_id id;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
|
||||
locked_print_initialize();
|
||||
|
||||
time.year = 1988;
|
||||
time.month = 12;
|
||||
time.day = 31;
|
||||
time.hour = 9;
|
||||
time.year = 1988;
|
||||
time.month = 12;
|
||||
time.day = 31;
|
||||
time.hour = 9;
|
||||
time.minute = 0;
|
||||
time.second = 0;
|
||||
time.ticks = 0;
|
||||
time.ticks = 0;
|
||||
|
||||
status = rtems_clock_set( &time );
|
||||
|
||||
/* Create/verify synchronisation semaphore */
|
||||
status = rtems_semaphore_create(
|
||||
rtems_build_name ('S', 'E', 'M', '1'),
|
||||
1,
|
||||
RTEMS_LOCAL |
|
||||
RTEMS_SIMPLE_BINARY_SEMAPHORE |
|
||||
RTEMS_PRIORITY,
|
||||
rtems_build_name( 'S', 'E', 'M', '1' ),
|
||||
1,
|
||||
RTEMS_LOCAL | RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY,
|
||||
1,
|
||||
&Semaphore
|
||||
);
|
||||
@@ -97,11 +94,10 @@ rtems_task Init(
|
||||
/* Show that the init task is running on this cpu */
|
||||
PrintTaskInfo( "Init", &time );
|
||||
|
||||
for ( i=1; i <= rtems_scheduler_get_processor_maximum() *3; i++ ) {
|
||||
|
||||
sprintf(ch, "%02" PRIu32, i );
|
||||
for ( i = 1; i <= rtems_scheduler_get_processor_maximum() * 3; i++ ) {
|
||||
sprintf( ch, "%02" PRIu32, i );
|
||||
status = rtems_task_create(
|
||||
rtems_build_name( 'T', 'A', ch[0], ch[1] ),
|
||||
rtems_build_name( 'T', 'A', ch[ 0 ], ch[ 1 ] ),
|
||||
2,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
@@ -110,7 +106,7 @@ rtems_task Init(
|
||||
);
|
||||
directive_failed( status, "task create" );
|
||||
|
||||
status = rtems_task_start( id, Test_task, i+1 );
|
||||
status = rtems_task_start( id, Test_task, i + 1 );
|
||||
directive_failed( status, "task start" );
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,9 @@
|
||||
|
||||
/* functions */
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Init( rtems_task_argument argument );
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Test_task( rtems_task_argument argument );
|
||||
|
||||
/* configuration information */
|
||||
|
||||
@@ -46,25 +42,21 @@ rtems_task Test_task(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS \
|
||||
(1 + (CONFIGURE_MAXIMUM_PROCESSORS*3) )
|
||||
#define CONFIGURE_MAXIMUM_TASKS ( 1 + ( CONFIGURE_MAXIMUM_PROCESSORS * 3 ) )
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
|
||||
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS ( 3 * RTEMS_MINIMUM_STACK_SIZE )
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
TEST_EXTERN rtems_id Semaphore; /* synchronisation semaphore */
|
||||
TEST_EXTERN rtems_id Semaphore; /* synchronisation semaphore */
|
||||
|
||||
void PrintTaskInfo(
|
||||
const char *task_name,
|
||||
rtems_time_of_day *_tb
|
||||
);
|
||||
void PrintTaskInfo( const char *task_name, rtems_time_of_day *_tb );
|
||||
|
||||
/* end of include file */
|
||||
|
||||
@@ -32,17 +32,15 @@
|
||||
|
||||
#include "system.h"
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument unused
|
||||
)
|
||||
rtems_task Test_task( rtems_task_argument unused )
|
||||
{
|
||||
(void) unused;
|
||||
|
||||
rtems_id tid;
|
||||
rtems_time_of_day time;
|
||||
uint32_t task_index;
|
||||
uint32_t task_index;
|
||||
rtems_status_code status;
|
||||
char name[5];
|
||||
char name[ 5 ];
|
||||
char *p;
|
||||
|
||||
/* Get the task name */
|
||||
@@ -52,7 +50,7 @@ rtems_task Test_task(
|
||||
status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
|
||||
rtems_test_assert( status == RTEMS_SUCCESSFUL );
|
||||
task_index = task_number( tid );
|
||||
for ( ; ; ) {
|
||||
for ( ;; ) {
|
||||
status = rtems_clock_get_tod( &time );
|
||||
rtems_test_assert( status == RTEMS_SUCCESSFUL );
|
||||
if ( time.second >= 35 ) {
|
||||
@@ -66,7 +64,8 @@ rtems_task Test_task(
|
||||
|
||||
PrintTaskInfo( p, &time );
|
||||
status = rtems_task_wake_after(
|
||||
task_index * 5 * rtems_clock_get_ticks_per_second() );
|
||||
task_index * 5 * rtems_clock_get_ticks_per_second()
|
||||
);
|
||||
rtems_test_assert( status == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,45 +38,35 @@ const char rtems_test_name[] = "SMP 9";
|
||||
|
||||
volatile int killtime;
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Init( rtems_task_argument argument );
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
rtems_task Test_task( rtems_task_argument argument );
|
||||
|
||||
rtems_task Test_task(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Test_task( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
while (1)
|
||||
;
|
||||
while ( 1 );
|
||||
/* XXX something goes here */
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
rtems_task Init( rtems_task_argument argument )
|
||||
{
|
||||
(void) argument;
|
||||
|
||||
uint32_t i;
|
||||
char ch;
|
||||
uint32_t cpu_num;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
uint32_t i;
|
||||
char ch;
|
||||
uint32_t cpu_num;
|
||||
rtems_id id;
|
||||
rtems_status_code status;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
locked_print_initialize();
|
||||
|
||||
for ( killtime=0; killtime<1000000; killtime++ )
|
||||
;
|
||||
|
||||
for ( i=0; i<rtems_scheduler_get_processor_maximum() -1; i++ ) {
|
||||
for ( killtime = 0; killtime < 1000000; killtime++ );
|
||||
|
||||
for ( i = 0; i < rtems_scheduler_get_processor_maximum() - 1; i++ ) {
|
||||
ch = '1' + i;
|
||||
|
||||
status = rtems_task_create(
|
||||
@@ -90,20 +80,19 @@ rtems_task Init(
|
||||
directive_failed( status, "task create" );
|
||||
|
||||
cpu_num = rtems_scheduler_get_processor();
|
||||
locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);
|
||||
locked_printf( " CPU %" PRIu32 " start task TA%c\n", cpu_num, ch );
|
||||
|
||||
status = rtems_task_start( id, Test_task, i+1 );
|
||||
status = rtems_task_start( id, Test_task, i + 1 );
|
||||
directive_failed( status, "task start" );
|
||||
}
|
||||
|
||||
locked_printf(" kill 10 clock ticks\n" );
|
||||
while ( rtems_clock_get_ticks_since_boot() < 10 )
|
||||
;
|
||||
locked_printf( " kill 10 clock ticks\n" );
|
||||
while ( rtems_clock_get_ticks_since_boot() < 10 );
|
||||
|
||||
rtems_cpu_usage_report();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
@@ -111,10 +100,9 @@ rtems_task Init(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 4
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS \
|
||||
(1 + CONFIGURE_MAXIMUM_PROCESSORS)
|
||||
#define CONFIGURE_MAXIMUM_TASKS ( 1 + CONFIGURE_MAXIMUM_PROCESSORS )
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
@@ -30,204 +30,213 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define NUM_CPUS 4
|
||||
#define NUM_CPUS 4
|
||||
|
||||
#include "tmacros.h"
|
||||
|
||||
const char rtems_test_name[] = "SMPAFFINITY 1";
|
||||
|
||||
rtems_id Init_id;
|
||||
rtems_id Med_id[NUM_CPUS-1];
|
||||
rtems_id Low_id[NUM_CPUS];
|
||||
rtems_id Init_id;
|
||||
rtems_id Med_id[ NUM_CPUS - 1 ];
|
||||
rtems_id Low_id[ NUM_CPUS ];
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
void Task_1(rtems_task_argument arg);
|
||||
void Validate_setaffinity_errors(void);
|
||||
void Validate_getaffinity_errors(void);
|
||||
void Validate_affinity(void);
|
||||
void Task_1( rtems_task_argument arg );
|
||||
void Validate_setaffinity_errors( void );
|
||||
void Validate_getaffinity_errors( void );
|
||||
void Validate_affinity( void );
|
||||
|
||||
void Task_1(rtems_task_argument arg)
|
||||
void Task_1( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
while(1);
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
void Validate_setaffinity_errors(void)
|
||||
void Validate_setaffinity_errors( void )
|
||||
{
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
/* Verify rtems_task_set_affinity checks that all cpu's exist. */
|
||||
/* Note this check assumes you are running with less than 32 CPUs */
|
||||
CPU_FILL(&cpuset);
|
||||
CPU_FILL( &cpuset );
|
||||
puts( "Init - rtems_task_set_affinity - Lots of cpus - SUCCESS" );
|
||||
sc = rtems_task_set_affinity( Init_id, sizeof(cpu_set_t), &cpuset );
|
||||
sc = rtems_task_set_affinity( Init_id, sizeof( cpu_set_t ), &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* Verify rtems_task_set_affinity checks that at least one cpu is set */
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_ZERO( &cpuset );
|
||||
puts( "Init - rtems_task_set_affinity - no cpu - RTEMS_INVALID_NUMBER" );
|
||||
sc = rtems_task_set_affinity( Init_id, sizeof(cpu_set_t), &cpuset );
|
||||
sc = rtems_task_set_affinity( Init_id, sizeof( cpu_set_t ), &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_INVALID_NUMBER );
|
||||
|
||||
/* Verify rtems_task_set_affinity checks that at thread id is valid */
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(0, &cpuset);
|
||||
CPU_ZERO( &cpuset );
|
||||
CPU_SET( 0, &cpuset );
|
||||
puts( "Init - rtems_task_set_affinity - Invalid thread - RTEMS_INVALID_ID" );
|
||||
sc = rtems_task_set_affinity( 999, sizeof(cpu_set_t), &cpuset );
|
||||
sc = rtems_task_set_affinity( 999, sizeof( cpu_set_t ), &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_INVALID_ID );
|
||||
|
||||
/* Verify rtems_task_set_affinity validates cpusetsize */
|
||||
puts( "Init - rtems_task_set_affinity - Invalid cpusetsize - RTEMS_INVALID_NUMBER" );
|
||||
sc = rtems_task_set_affinity( Init_id, 1, &cpuset );
|
||||
puts(
|
||||
"Init - rtems_task_set_affinity - Invalid cpusetsize - RTEMS_INVALID_NUMBER"
|
||||
);
|
||||
sc = rtems_task_set_affinity( Init_id, 1, &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_INVALID_NUMBER );
|
||||
|
||||
/* Verifyrtems_task_set_affinity validates cpuset */
|
||||
puts( "Init - rtems_task_set_affinity - Invalid cpuset - RTEMS_INVALID_ADDRESS" );
|
||||
sc = rtems_task_set_affinity( Init_id, sizeof(cpu_set_t), NULL );
|
||||
puts(
|
||||
"Init - rtems_task_set_affinity - Invalid cpuset - RTEMS_INVALID_ADDRESS"
|
||||
);
|
||||
sc = rtems_task_set_affinity( Init_id, sizeof( cpu_set_t ), NULL );
|
||||
rtems_test_assert( sc == RTEMS_INVALID_ADDRESS );
|
||||
}
|
||||
|
||||
void Validate_getaffinity_errors(void)
|
||||
void Validate_getaffinity_errors( void )
|
||||
{
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
/* Verify rtems_task_get_affinity checks that at thread id is valid */
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(0, &cpuset);
|
||||
CPU_ZERO( &cpuset );
|
||||
CPU_SET( 0, &cpuset );
|
||||
puts( "Init - rtems_task_get_affinity - Invalid thread - RTEMS_INVALID_ID" );
|
||||
sc = rtems_task_get_affinity( 999, sizeof(cpu_set_t), &cpuset );
|
||||
sc = rtems_task_get_affinity( 999, sizeof( cpu_set_t ), &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_INVALID_ID );
|
||||
|
||||
/* Verify rtems_task_get_affinity validates cpusetsize */
|
||||
puts(
|
||||
"Init - rtems_task_get_affinity - Invalid cpusetsize - RTEMS_INVALID_NUMBER"
|
||||
);
|
||||
sc = rtems_task_get_affinity( Init_id, 1, &cpuset );
|
||||
sc = rtems_task_get_affinity( Init_id, 1, &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_INVALID_SIZE );
|
||||
|
||||
/* Verify rtems_task_get_affinity validates cpuset */
|
||||
puts("Init - rtems_task_get_affinity - Invalid cpuset - RTEMS_INVALID_ADDRESS");
|
||||
sc = rtems_task_get_affinity( Init_id, sizeof(cpu_set_t), NULL );
|
||||
puts(
|
||||
"Init - rtems_task_get_affinity - Invalid cpuset - RTEMS_INVALID_ADDRESS"
|
||||
);
|
||||
sc = rtems_task_get_affinity( Init_id, sizeof( cpu_set_t ), NULL );
|
||||
rtems_test_assert( sc == RTEMS_INVALID_ADDRESS );
|
||||
}
|
||||
|
||||
void Validate_affinity(void )
|
||||
void Validate_affinity( void )
|
||||
{
|
||||
cpu_set_t cpuset0;
|
||||
cpu_set_t cpuset1;
|
||||
cpu_set_t cpuset2;
|
||||
int i;
|
||||
int sc;
|
||||
int cpu_count;
|
||||
rtems_task_priority priority;
|
||||
char ch[2];
|
||||
cpu_set_t cpuset0;
|
||||
cpu_set_t cpuset1;
|
||||
cpu_set_t cpuset2;
|
||||
int i;
|
||||
int sc;
|
||||
int cpu_count;
|
||||
rtems_task_priority priority;
|
||||
char ch[ 2 ];
|
||||
|
||||
puts( "Init - Set Init priority to high");
|
||||
puts( "Init - Set Init priority to high" );
|
||||
sc = rtems_task_set_priority( Init_id, 1, &priority );
|
||||
directive_failed( sc, "Set Init Priority" );
|
||||
|
||||
sc = rtems_task_get_affinity( Init_id, sizeof(cpu_set_t), &cpuset0 );
|
||||
sc = rtems_task_get_affinity( Init_id, sizeof( cpu_set_t ), &cpuset0 );
|
||||
directive_failed( sc, "Get Affinity of Init Task" );
|
||||
|
||||
/* Get the number of processors that we are using. */
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
|
||||
/* Fill the remaining cpus with med priority tasks */
|
||||
puts( "Init - Create Medium priority tasks");
|
||||
for (i=0; i<(cpu_count-1); i++){
|
||||
sprintf(ch, "%01" PRId32, i+1 );
|
||||
puts( "Init - Create Medium priority tasks" );
|
||||
for ( i = 0; i < ( cpu_count - 1 ); i++ ) {
|
||||
sprintf( ch, "%01" PRId32, i + 1 );
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name( 'C', 'P', 'U', ch[0] ),
|
||||
rtems_build_name( 'C', 'P', 'U', ch[ 0 ] ),
|
||||
2,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&Med_id[i]
|
||||
&Med_id[ i ]
|
||||
);
|
||||
directive_failed( sc, "task create" );
|
||||
|
||||
sc = rtems_task_start( Med_id[i], Task_1, i+1 );
|
||||
sc = rtems_task_start( Med_id[ i ], Task_1, i + 1 );
|
||||
directive_failed( sc, "task start" );
|
||||
|
||||
sc = rtems_task_get_affinity( Med_id[i], sizeof(cpu_set_t), &cpuset2 );
|
||||
sc = rtems_task_get_affinity( Med_id[ i ], sizeof( cpu_set_t ), &cpuset2 );
|
||||
directive_failed( sc, "Get Affinity of Medium Priority Task" );
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset0, &cpuset2) );
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset0, &cpuset2 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Create low priority thread for each remaining cpu with the affinity
|
||||
* set to only run on one cpu.
|
||||
*/
|
||||
puts( "Init - Create Low priority tasks");
|
||||
for (i=0; i<cpu_count; i++){
|
||||
CPU_ZERO(&cpuset1);
|
||||
CPU_SET(i, &cpuset1);
|
||||
puts( "Init - Create Low priority tasks" );
|
||||
for ( i = 0; i < cpu_count; i++ ) {
|
||||
CPU_ZERO( &cpuset1 );
|
||||
CPU_SET( i, &cpuset1 );
|
||||
|
||||
sprintf(ch, "%01" PRId32, (uint32_t) 0 );
|
||||
sprintf( ch, "%01" PRId32, (uint32_t) 0 );
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name( 'X', 'T', 'R', ch[0] ),
|
||||
rtems_build_name( 'X', 'T', 'R', ch[ 0 ] ),
|
||||
10,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&Low_id[i]
|
||||
&Low_id[ i ]
|
||||
);
|
||||
directive_failed( sc, "task create" );
|
||||
|
||||
sc = rtems_task_set_affinity( Low_id[i], sizeof(cpu_set_t), &cpuset1 );
|
||||
sc = rtems_task_set_affinity( Low_id[ i ], sizeof( cpu_set_t ), &cpuset1 );
|
||||
directive_failed( sc, "Low priority task set affinity" );
|
||||
|
||||
sc = rtems_task_start( Low_id[i], Task_1, i+1 );
|
||||
sc = rtems_task_start( Low_id[ i ], Task_1, i + 1 );
|
||||
directive_failed( sc, "task start" );
|
||||
}
|
||||
|
||||
|
||||
/* Verify affinity on low priority tasks */
|
||||
puts("Init - Verify affinity on Low priority tasks");
|
||||
for (i=0; i<cpu_count; i++){
|
||||
CPU_ZERO(&cpuset1);
|
||||
CPU_SET(i, &cpuset1);
|
||||
puts( "Init - Verify affinity on Low priority tasks" );
|
||||
for ( i = 0; i < cpu_count; i++ ) {
|
||||
CPU_ZERO( &cpuset1 );
|
||||
CPU_SET( i, &cpuset1 );
|
||||
|
||||
sc = rtems_task_get_affinity( Low_id[i], sizeof(cpu_set_t), &cpuset2 );
|
||||
sc = rtems_task_get_affinity( Low_id[ i ], sizeof( cpu_set_t ), &cpuset2 );
|
||||
directive_failed( sc, "Low priority task get affinity" );
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset1, &cpuset2) );
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset1, &cpuset2 ) );
|
||||
}
|
||||
|
||||
/* Change the affinity for each low priority task */
|
||||
puts("Init - Change affinity on Low priority tasks");
|
||||
CPU_COPY(&cpuset0, &cpuset1);
|
||||
for (i=0; i<cpu_count; i++){
|
||||
|
||||
CPU_CLR(i, &cpuset1);
|
||||
sc = rtems_task_set_affinity( Low_id[i], sizeof(cpu_set_t), &cpuset1 );
|
||||
puts( "Init - Change affinity on Low priority tasks" );
|
||||
CPU_COPY( &cpuset0, &cpuset1 );
|
||||
for ( i = 0; i < cpu_count; i++ ) {
|
||||
CPU_CLR( i, &cpuset1 );
|
||||
sc = rtems_task_set_affinity( Low_id[ i ], sizeof( cpu_set_t ), &cpuset1 );
|
||||
|
||||
/* Verify no cpu's are now set in the cpuset */
|
||||
if (i== (cpu_count-1)) {
|
||||
if ( i == ( cpu_count - 1 ) ) {
|
||||
rtems_test_assert( sc == RTEMS_INVALID_NUMBER );
|
||||
sc = rtems_task_set_affinity( Low_id[i], sizeof(cpu_set_t), &cpuset0 );
|
||||
sc = rtems_task_set_affinity(
|
||||
Low_id[ i ],
|
||||
sizeof( cpu_set_t ),
|
||||
&cpuset0
|
||||
);
|
||||
}
|
||||
|
||||
directive_failed( sc, "Low priority task set affinity" );
|
||||
}
|
||||
|
||||
puts("Init - Validate affinity on Low priority tasks");
|
||||
CPU_COPY(&cpuset0, &cpuset1);
|
||||
for (i=0; i<cpu_count; i++){
|
||||
CPU_CLR(i, &cpuset1);
|
||||
puts( "Init - Validate affinity on Low priority tasks" );
|
||||
CPU_COPY( &cpuset0, &cpuset1 );
|
||||
for ( i = 0; i < cpu_count; i++ ) {
|
||||
CPU_CLR( i, &cpuset1 );
|
||||
|
||||
sc = rtems_task_get_affinity( Low_id[i], sizeof(cpu_set_t), &cpuset2 );
|
||||
sc = rtems_task_get_affinity( Low_id[ i ], sizeof( cpu_set_t ), &cpuset2 );
|
||||
directive_failed( sc, "Low priority task get affinity" );
|
||||
if (i== (cpu_count-1))
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset0, &cpuset2) );
|
||||
else
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset1, &cpuset2) );
|
||||
if ( i == ( cpu_count - 1 ) ) {
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset0, &cpuset2 ) );
|
||||
} else {
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset1, &cpuset2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -244,7 +253,7 @@ static void Init(rtems_task_argument arg)
|
||||
Validate_affinity();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -254,7 +263,7 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS NUM_CPUS
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS (NUM_CPUS*2)
|
||||
#define CONFIGURE_MAXIMUM_TASKS ( NUM_CPUS * 2 )
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,8 +48,8 @@ const char rtems_test_name[] = "SMPCACHE 1";
|
||||
|
||||
typedef struct {
|
||||
SMP_barrier_Control barrier;
|
||||
bool do_longjmp[CPU_COUNT];
|
||||
jmp_buf instruction_invalidate_return_context[CPU_COUNT];
|
||||
bool do_longjmp[ CPU_COUNT ];
|
||||
jmp_buf instruction_invalidate_return_context[ CPU_COUNT ];
|
||||
} test_context;
|
||||
|
||||
static test_context ctx = {
|
||||
@@ -72,14 +72,16 @@ static void test_cache_invalidate_multiple_instruction_lines( void )
|
||||
{
|
||||
uint32_t self = rtems_scheduler_get_processor();
|
||||
|
||||
ctx.do_longjmp[self] = true;
|
||||
ctx.do_longjmp[ self ] = true;
|
||||
|
||||
if (setjmp(ctx.instruction_invalidate_return_context[self]) == 0) {
|
||||
rtems_cache_invalidate_multiple_instruction_lines( &function_to_flush,
|
||||
4 /* arbitrary size */ );
|
||||
if ( setjmp( ctx.instruction_invalidate_return_context[ self ] ) == 0 ) {
|
||||
rtems_cache_invalidate_multiple_instruction_lines(
|
||||
&function_to_flush,
|
||||
4 /* arbitrary size */
|
||||
);
|
||||
}
|
||||
|
||||
ctx.do_longjmp[self] = false;
|
||||
ctx.do_longjmp[ self ] = false;
|
||||
}
|
||||
|
||||
static void barrier( SMP_barrier_State *bs )
|
||||
@@ -100,7 +102,7 @@ static void call_tests( SMP_barrier_State *bs )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
|
||||
for ( i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i ) {
|
||||
barrier( bs );
|
||||
( *test_cases[ i ] )();
|
||||
barrier( bs );
|
||||
@@ -111,7 +113,7 @@ static void call_tests_isr_disabled( SMP_barrier_State *bs )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
|
||||
for ( i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i ) {
|
||||
ISR_Level isr_level;
|
||||
|
||||
_ISR_Local_disable( isr_level );
|
||||
@@ -126,7 +128,7 @@ static void call_tests_with_thread_dispatch_disabled( SMP_barrier_State *bs )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
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;
|
||||
|
||||
cpu_self = _Thread_Dispatch_disable();
|
||||
@@ -137,10 +139,11 @@ static void call_tests_with_thread_dispatch_disabled( SMP_barrier_State *bs )
|
||||
}
|
||||
}
|
||||
|
||||
static void cmlog( const char* str )
|
||||
static void cmlog( const char *str )
|
||||
{
|
||||
if ( rtems_scheduler_get_processor() == 0 )
|
||||
if ( rtems_scheduler_get_processor() == 0 ) {
|
||||
printf( "%s", str );
|
||||
}
|
||||
}
|
||||
|
||||
static void all_tests( void )
|
||||
@@ -150,7 +153,7 @@ static void all_tests( void )
|
||||
/* Call test cases */
|
||||
cmlog( "Calling test cases. " );
|
||||
call_tests( &bs );
|
||||
cmlog( "Done!\n");
|
||||
cmlog( "Done!\n" );
|
||||
|
||||
/* Call test cases with ISR disabled */
|
||||
cmlog( "Calling test cases with ISR disabled. " );
|
||||
@@ -158,9 +161,9 @@ static void all_tests( void )
|
||||
cmlog( "Done!\n" );
|
||||
|
||||
/* 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( &bs );
|
||||
cmlog( "Done!\n");
|
||||
cmlog( "Done!\n" );
|
||||
|
||||
/* Done. Free up memory. */
|
||||
_SMP_barrier_Wait(
|
||||
@@ -170,7 +173,7 @@ static void all_tests( void )
|
||||
);
|
||||
}
|
||||
|
||||
static void worker_task(rtems_task_argument arg)
|
||||
static void worker_task( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -178,21 +181,21 @@ static void worker_task(rtems_task_argument arg)
|
||||
|
||||
all_tests();
|
||||
|
||||
sc = rtems_task_suspend(RTEMS_SELF);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_suspend( RTEMS_SELF );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
static void test_smp_cache_manager( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
size_t worker_index;
|
||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
size_t worker_index;
|
||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
|
||||
for (worker_index = 1; worker_index < cpu_count; ++worker_index) {
|
||||
for ( worker_index = 1; worker_index < cpu_count; ++worker_index ) {
|
||||
rtems_id worker_id;
|
||||
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('W', 'R', 'K', '0'+worker_index),
|
||||
rtems_build_name( 'W', 'R', 'K', '0' + worker_index ),
|
||||
WORKER_PRIORITY,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
@@ -208,8 +211,7 @@ static void test_smp_cache_manager( void )
|
||||
all_tests();
|
||||
}
|
||||
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -218,13 +220,13 @@ static void Init(rtems_task_argument arg)
|
||||
test_smp_cache_manager();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code error
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code error
|
||||
)
|
||||
{
|
||||
(void) always_set_to_false;
|
||||
@@ -232,9 +234,9 @@ static void fatal_extension(
|
||||
|
||||
uint32_t self = rtems_scheduler_get_processor();
|
||||
|
||||
if (source == RTEMS_FATAL_SOURCE_EXCEPTION && ctx.do_longjmp[self]) {
|
||||
_ISR_Set_level(0);
|
||||
longjmp(ctx.instruction_invalidate_return_context[self], 1);
|
||||
if ( source == RTEMS_FATAL_SOURCE_EXCEPTION && ctx.do_longjmp[ self ] ) {
|
||||
_ISR_Set_level( 0 );
|
||||
longjmp( ctx.instruction_invalidate_return_context[ self ], 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,8 +250,7 @@ static void fatal_extension(
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
|
||||
@@ -64,58 +64,60 @@ struct task_data_t {
|
||||
int migrate_cpu;
|
||||
};
|
||||
|
||||
static struct task_data_t task_data[TASK_COUNT] = {
|
||||
{0x0, {{0xc}}, 7, false, 3, -1, 2},
|
||||
{0x0, {{0xf}}, 8, false, 2, -1, -1},
|
||||
{0x0, {{0x3}}, 5, false, 1, -1, 0},
|
||||
{0x0, {{0x9}}, 6, false, 0, -1, 3},
|
||||
{0x0, {{0x2}}, 9, false, -1, -1, 1}
|
||||
static struct task_data_t task_data[ TASK_COUNT ] = {
|
||||
{ 0x0, { { 0xc } }, 7, false, 3, -1, 2 },
|
||||
{ 0x0, { { 0xf } }, 8, false, 2, -1, -1 },
|
||||
{ 0x0, { { 0x3 } }, 5, false, 1, -1, 0 },
|
||||
{ 0x0, { { 0x9 } }, 6, false, 0, -1, 3 },
|
||||
{ 0x0, { { 0x2 } }, 9, false, -1, -1, 1 }
|
||||
};
|
||||
|
||||
rtems_id task_sem;
|
||||
rtems_id task_sem;
|
||||
|
||||
/*
|
||||
* Spin loop to allow tasks to delay without yeilding the
|
||||
* processor.
|
||||
*/
|
||||
static void test_delay(rtems_interval ticks)
|
||||
static void test_delay( rtems_interval ticks )
|
||||
{
|
||||
rtems_interval start, stop;
|
||||
start = rtems_clock_get_ticks_since_boot();
|
||||
do {
|
||||
stop = rtems_clock_get_ticks_since_boot();
|
||||
} while ( (stop - start) < ticks );
|
||||
} while ( ( stop - start ) < ticks );
|
||||
}
|
||||
|
||||
static void task(rtems_task_argument arg)
|
||||
static void task( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
rtems_status_code sc;
|
||||
rtems_status_code sc;
|
||||
|
||||
while (true) {
|
||||
sc = rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0);
|
||||
if (sc == RTEMS_SUCCESSFUL) {
|
||||
task_data[arg].ran = true;
|
||||
task_data[arg].actual_cpu = rtems_scheduler_get_processor();
|
||||
rtems_semaphore_release(task_sem);
|
||||
test_delay(1);
|
||||
while ( true ) {
|
||||
sc = rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 );
|
||||
if ( sc == RTEMS_SUCCESSFUL ) {
|
||||
task_data[ arg ].ran = true;
|
||||
task_data[ arg ].actual_cpu = rtems_scheduler_get_processor();
|
||||
rtems_semaphore_release( task_sem );
|
||||
test_delay( 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void set_init_task(void)
|
||||
static void set_init_task( void )
|
||||
{
|
||||
while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
|
||||
while (
|
||||
rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 ) != RTEMS_SUCCESSFUL
|
||||
);
|
||||
|
||||
/* Set Init task data */
|
||||
task_data[0].ran = true;
|
||||
task_data[0].actual_cpu = rtems_scheduler_get_processor();
|
||||
task_data[ 0 ].ran = true;
|
||||
task_data[ 0 ].actual_cpu = rtems_scheduler_get_processor();
|
||||
|
||||
rtems_semaphore_release(task_sem);
|
||||
rtems_semaphore_release( task_sem );
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_task_argument i;
|
||||
@@ -125,61 +127,56 @@ static void test(void)
|
||||
|
||||
/* Get the number of processors that we are using. */
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
if (cpu_count != 4) {
|
||||
printf("Test requires a minimum of 4 cores\n");
|
||||
if ( cpu_count != 4 ) {
|
||||
printf( "Test requires a minimum of 4 cores\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
size = sizeof(cpu_set_t);
|
||||
task_data[0].id = rtems_task_self();
|
||||
size = sizeof( cpu_set_t );
|
||||
task_data[ 0 ].id = rtems_task_self();
|
||||
|
||||
sc = rtems_semaphore_create(
|
||||
rtems_build_name('S', 'E', 'M', '0'),
|
||||
1, /* initial count = 1 */
|
||||
RTEMS_LOCAL |
|
||||
RTEMS_SIMPLE_BINARY_SEMAPHORE |
|
||||
RTEMS_NO_INHERIT_PRIORITY |
|
||||
RTEMS_NO_PRIORITY_CEILING |
|
||||
RTEMS_FIFO,
|
||||
rtems_build_name( 'S', 'E', 'M', '0' ),
|
||||
1, /* initial count = 1 */
|
||||
RTEMS_LOCAL | RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_NO_INHERIT_PRIORITY |
|
||||
RTEMS_NO_PRIORITY_CEILING | RTEMS_FIFO,
|
||||
0,
|
||||
&task_sem
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_set_affinity(
|
||||
task_data[ 0 ].id,
|
||||
size,
|
||||
&task_data[0].cpuset
|
||||
&task_data[ 0 ].cpuset
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* Create and start tasks on each cpu with the appropriate affinity. */
|
||||
for (i = 1; i < TASK_COUNT; i++) {
|
||||
for ( i = 1; i < TASK_COUNT; i++ ) {
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name( 'T', 'A', '0', '0' + i ),
|
||||
task_data[ i ].priority,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_data[ i ].id
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('T', 'A', '0', '0'+i),
|
||||
task_data[ i ].priority,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_data[ i ].id
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_affinity(
|
||||
task_data[ i ].id,
|
||||
size,
|
||||
&task_data[ i ].cpuset
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_set_affinity(
|
||||
task_data[ i ].id,
|
||||
size,
|
||||
&task_data[i].cpuset
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
sc = rtems_task_start( task_data[ i ].id, task, i );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_start( task_data[ i ].id, task, i );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
/* spin for 10 ticks */
|
||||
test_delay(10);
|
||||
test_delay( 10 );
|
||||
|
||||
set_init_task();
|
||||
|
||||
@@ -190,50 +187,53 @@ static void test(void)
|
||||
task_data[ i ].priority,
|
||||
&priority
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
test_delay(10);
|
||||
test_delay( 10 );
|
||||
|
||||
while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
|
||||
for (i = 0; i < TASK_COUNT; i++) {
|
||||
while (
|
||||
rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 ) != RTEMS_SUCCESSFUL
|
||||
);
|
||||
for ( i = 0; i < TASK_COUNT; i++ ) {
|
||||
task_data[ i ].expected_cpu = task_data[ i ].migrate_cpu;
|
||||
task_data[ i ].actual_cpu = -1;
|
||||
task_data[ i ].ran = false;
|
||||
}
|
||||
rtems_semaphore_release(task_sem);
|
||||
test_delay(10);
|
||||
rtems_semaphore_release( task_sem );
|
||||
test_delay( 10 );
|
||||
set_init_task();
|
||||
|
||||
for (i = 1; i < TASK_COUNT; i++) {
|
||||
for ( i = 1; i < TASK_COUNT; i++ ) {
|
||||
sc = rtems_task_delete( task_data[ i ].id );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
test_delay(25);
|
||||
test_delay( 25 );
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
rtems_status_code sc;
|
||||
rtems_name to_name = rtems_build_name('I', 'D', 'L', 'E');;
|
||||
uint32_t i;
|
||||
rtems_status_code sc;
|
||||
rtems_name to_name = rtems_build_name( 'I', 'D', 'L', 'E' );
|
||||
;
|
||||
uint32_t i;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
sc = rtems_capture_open (5000, NULL);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_capture_open( 5000, NULL );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_capture_watch_ceiling (0);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_capture_watch_ceiling( 0 );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_capture_watch_floor (20);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_capture_watch_floor( 20 );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_capture_watch_global (true);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_capture_watch_global( true );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_capture_set_trigger (
|
||||
sc = rtems_capture_set_trigger(
|
||||
0,
|
||||
0,
|
||||
to_name,
|
||||
@@ -241,11 +241,11 @@ static void Init(rtems_task_argument arg)
|
||||
rtems_capture_from_any,
|
||||
rtems_capture_switch
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
for (i = 1; i < TASK_COUNT; i++) {
|
||||
to_name = rtems_build_name('T', 'A', '0', '0'+i);
|
||||
sc = rtems_capture_set_trigger (
|
||||
for ( i = 1; i < TASK_COUNT; i++ ) {
|
||||
to_name = rtems_build_name( 'T', 'A', '0', '0' + i );
|
||||
sc = rtems_capture_set_trigger(
|
||||
0,
|
||||
0,
|
||||
to_name,
|
||||
@@ -255,20 +255,20 @@ static void Init(rtems_task_argument arg)
|
||||
);
|
||||
}
|
||||
|
||||
sc = rtems_capture_set_control (true);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_capture_set_control( true );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
test();
|
||||
|
||||
sc = rtems_capture_set_control (false);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_capture_set_control( false );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
rtems_capture_print_trace_records ( 22, false );
|
||||
rtems_capture_print_trace_records ( 22, false );
|
||||
rtems_capture_print_trace_records ( 22, false );
|
||||
rtems_capture_print_trace_records( 22, false );
|
||||
rtems_capture_print_trace_records( 22, false );
|
||||
rtems_capture_print_trace_records( 22, false );
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -282,14 +282,15 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 7
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 7
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
|
||||
|
||||
#define TASK_ALLOCATION_SIZE (5)
|
||||
#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(TASK_ALLOCATION_SIZE)
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS (75 * RTEMS_MINIMUM_STACK_SIZE)
|
||||
#define TASK_ALLOCATION_SIZE ( 5 )
|
||||
#define CONFIGURE_MAXIMUM_TASKS \
|
||||
rtems_resource_unlimited( TASK_ALLOCATION_SIZE )
|
||||
#define CONFIGURE_EXTRA_TASK_STACKS ( 75 * RTEMS_MINIMUM_STACK_SIZE )
|
||||
|
||||
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS (5)
|
||||
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS ( 5 )
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -40,16 +40,16 @@
|
||||
|
||||
#define CPU_COUNT 2
|
||||
|
||||
#define SCHEDULER_A rtems_build_name(' ', ' ', ' ', 'A')
|
||||
#define SCHEDULER_A rtems_build_name( ' ', ' ', ' ', 'A' )
|
||||
|
||||
#define SCHEDULER_B rtems_build_name(' ', ' ', ' ', 'B')
|
||||
#define SCHEDULER_B rtems_build_name( ' ', ' ', ' ', 'B' )
|
||||
|
||||
const char rtems_test_name[] = "SMPCLOCK 1";
|
||||
|
||||
typedef struct {
|
||||
SMP_barrier_Control barrier;
|
||||
SMP_barrier_State delay_barrier_state;
|
||||
SMP_barrier_State timer_barrier_state;
|
||||
SMP_barrier_State delay_barrier_state;
|
||||
SMP_barrier_State timer_barrier_state;
|
||||
} test_context;
|
||||
|
||||
static test_context test_instance = {
|
||||
@@ -58,95 +58,95 @@ static test_context test_instance = {
|
||||
.timer_barrier_state = SMP_BARRIER_STATE_INITIALIZER
|
||||
};
|
||||
|
||||
static void wait(test_context *ctx, SMP_barrier_State *bs)
|
||||
static void wait( test_context *ctx, SMP_barrier_State *bs )
|
||||
{
|
||||
_SMP_barrier_Wait(&ctx->barrier, bs, CPU_COUNT);
|
||||
_SMP_barrier_Wait( &ctx->barrier, bs, CPU_COUNT );
|
||||
}
|
||||
|
||||
static void timer_isr(rtems_id id, void *arg)
|
||||
static void timer_isr( rtems_id id, void *arg )
|
||||
{
|
||||
(void) id;
|
||||
|
||||
test_context *ctx = arg;
|
||||
|
||||
/* (B) */
|
||||
wait(ctx, &ctx->timer_barrier_state);
|
||||
wait( ctx, &ctx->timer_barrier_state );
|
||||
}
|
||||
|
||||
static void timer_task(rtems_task_argument arg)
|
||||
static void timer_task( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
test_context *ctx = (test_context *) arg;
|
||||
test_context *ctx = (test_context *) arg;
|
||||
rtems_status_code sc;
|
||||
rtems_id timer_id;
|
||||
rtems_id timer_id;
|
||||
|
||||
rtems_test_assert(rtems_scheduler_get_processor() == 1);
|
||||
rtems_test_assert( rtems_scheduler_get_processor() == 1 );
|
||||
|
||||
sc = rtems_timer_create(SCHEDULER_B, &timer_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_timer_create( SCHEDULER_B, &timer_id );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* (A) */
|
||||
wait(ctx, &ctx->timer_barrier_state);
|
||||
wait( ctx, &ctx->timer_barrier_state );
|
||||
|
||||
sc = rtems_timer_fire_after(timer_id, 1, timer_isr, ctx);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_timer_fire_after( timer_id, 1, timer_isr, ctx );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_wake_after(1);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_wake_after( 1 );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_timer_delete(timer_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_timer_delete( timer_id );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* (C) */
|
||||
wait(ctx, &ctx->timer_barrier_state);
|
||||
wait( ctx, &ctx->timer_barrier_state );
|
||||
|
||||
while (true) {
|
||||
while ( true ) {
|
||||
/* Wait for deletion */
|
||||
}
|
||||
}
|
||||
|
||||
static void delay_clock_tick(test_context *ctx)
|
||||
static void delay_clock_tick( test_context *ctx )
|
||||
{
|
||||
rtems_interrupt_level level;
|
||||
const Per_CPU_Control *cpu_self = _Per_CPU_Get_by_index(0);
|
||||
const Per_CPU_Control *cpu_other = _Per_CPU_Get_by_index(1);
|
||||
uint64_t ticks;
|
||||
rtems_interrupt_level level;
|
||||
const Per_CPU_Control *cpu_self = _Per_CPU_Get_by_index( 0 );
|
||||
const Per_CPU_Control *cpu_other = _Per_CPU_Get_by_index( 1 );
|
||||
uint64_t ticks;
|
||||
|
||||
rtems_test_assert(rtems_scheduler_get_processor() == 0);
|
||||
rtems_test_assert( rtems_scheduler_get_processor() == 0 );
|
||||
|
||||
rtems_test_spin_until_next_tick();
|
||||
ticks = cpu_self->Watchdog.ticks;
|
||||
|
||||
rtems_interrupt_local_disable(level);
|
||||
rtems_interrupt_local_disable( level );
|
||||
|
||||
/* (A) */
|
||||
wait(ctx, &ctx->delay_barrier_state);
|
||||
wait( ctx, &ctx->delay_barrier_state );
|
||||
|
||||
/* (B) */
|
||||
wait(ctx, &ctx->delay_barrier_state);
|
||||
wait( ctx, &ctx->delay_barrier_state );
|
||||
|
||||
rtems_test_assert(cpu_self->Watchdog.ticks == ticks);
|
||||
rtems_test_assert(cpu_other->Watchdog.ticks == ticks + 1);
|
||||
rtems_test_assert( cpu_self->Watchdog.ticks == ticks );
|
||||
rtems_test_assert( cpu_other->Watchdog.ticks == ticks + 1 );
|
||||
|
||||
rtems_interrupt_local_enable(level);
|
||||
rtems_interrupt_local_enable( level );
|
||||
|
||||
rtems_test_assert(cpu_self->Watchdog.ticks == ticks + 1);
|
||||
rtems_test_assert(cpu_other->Watchdog.ticks == ticks + 1);
|
||||
rtems_test_assert( cpu_self->Watchdog.ticks == ticks + 1 );
|
||||
rtems_test_assert( cpu_other->Watchdog.ticks == ticks + 1 );
|
||||
|
||||
/* (C) */
|
||||
wait(ctx, &ctx->delay_barrier_state);
|
||||
wait( ctx, &ctx->delay_barrier_state );
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
test_context *ctx = &test_instance;
|
||||
test_context *ctx = &test_instance;
|
||||
rtems_status_code sc;
|
||||
rtems_id scheduler_b_id;
|
||||
rtems_id task_id;
|
||||
rtems_id scheduler_b_id;
|
||||
rtems_id task_id;
|
||||
|
||||
sc = rtems_scheduler_ident(SCHEDULER_B, &scheduler_b_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_scheduler_ident( SCHEDULER_B, &scheduler_b_id );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_create(
|
||||
SCHEDULER_B,
|
||||
@@ -156,21 +156,21 @@ static void test(void)
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_id
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_set_scheduler(task_id, scheduler_b_id, 1);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_scheduler( task_id, scheduler_b_id, 1 );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_start(task_id, timer_task, (rtems_task_argument) ctx);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_start( task_id, timer_task, (rtems_task_argument) ctx );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
delay_clock_tick(ctx);
|
||||
delay_clock_tick( ctx );
|
||||
|
||||
sc = rtems_task_delete(task_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_delete( task_id );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -178,16 +178,16 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
rtems_resource_snapshot_take(&snapshot);
|
||||
rtems_resource_snapshot_take( &snapshot );
|
||||
|
||||
if (rtems_scheduler_get_processor_maximum() == CPU_COUNT) {
|
||||
if ( rtems_scheduler_get_processor_maximum() == CPU_COUNT ) {
|
||||
test();
|
||||
}
|
||||
|
||||
rtems_test_assert(rtems_resource_snapshot_check(&snapshot));
|
||||
rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -199,16 +199,16 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#include <rtems/scheduler.h>
|
||||
|
||||
RTEMS_SCHEDULER_SIMPLE_SMP(a);
|
||||
RTEMS_SCHEDULER_SIMPLE_SMP(b);
|
||||
RTEMS_SCHEDULER_SIMPLE_SMP( a );
|
||||
RTEMS_SCHEDULER_SIMPLE_SMP( b );
|
||||
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_SIMPLE_SMP(a, SCHEDULER_A), \
|
||||
RTEMS_SCHEDULER_TABLE_SIMPLE_SMP(b, SCHEDULER_B)
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( a, SCHEDULER_A ), \
|
||||
RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( b, SCHEDULER_B )
|
||||
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
|
||||
RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL)
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \
|
||||
RTEMS_SCHEDULER_ASSIGN( 1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL )
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS CPU_COUNT
|
||||
|
||||
|
||||
@@ -49,78 +49,76 @@ static uint32_t other_cpu;
|
||||
|
||||
static SMP_barrier_Control barrier = SMP_BARRIER_CONTROL_INITIALIZER;
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
assert(0);
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
)
|
||||
{
|
||||
assert(!always_set_to_false);
|
||||
assert( !always_set_to_false );
|
||||
|
||||
if (source == RTEMS_FATAL_SOURCE_SMP) {
|
||||
if ( source == RTEMS_FATAL_SOURCE_SMP ) {
|
||||
SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER;
|
||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
uint32_t self = rtems_scheduler_get_processor();
|
||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
uint32_t self = rtems_scheduler_get_processor();
|
||||
|
||||
if (self == other_cpu) {
|
||||
assert(code == SMP_FATAL_SHUTDOWN);
|
||||
if ( self == other_cpu ) {
|
||||
assert( code == SMP_FATAL_SHUTDOWN );
|
||||
} else {
|
||||
assert(code == SMP_FATAL_SHUTDOWN_RESPONSE);
|
||||
assert( code == SMP_FATAL_SHUTDOWN_RESPONSE );
|
||||
}
|
||||
|
||||
_SMP_barrier_Wait(&barrier, &barrier_state, cpu_count);
|
||||
_SMP_barrier_Wait( &barrier, &barrier_state, cpu_count );
|
||||
|
||||
if (self == other_cpu) {
|
||||
if ( self == other_cpu ) {
|
||||
uint32_t cpu;
|
||||
|
||||
for (cpu = 0; cpu < cpu_count; ++cpu) {
|
||||
for ( cpu = 0; cpu < cpu_count; ++cpu ) {
|
||||
const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
|
||||
Per_CPU_State state = _Per_CPU_Get_state(per_cpu);
|
||||
Per_CPU_State state = _Per_CPU_Get_state( per_cpu );
|
||||
|
||||
assert(state == PER_CPU_STATE_SHUTDOWN);
|
||||
assert( state == PER_CPU_STATE_SHUTDOWN );
|
||||
}
|
||||
|
||||
for (cpu = cpu_count; cpu < MAX_CPUS; ++cpu) {
|
||||
for ( cpu = cpu_count; cpu < MAX_CPUS; ++cpu ) {
|
||||
const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
|
||||
Per_CPU_State state = _Per_CPU_Get_state(per_cpu);
|
||||
Per_CPU_State state = _Per_CPU_Get_state( per_cpu );
|
||||
|
||||
assert(state == PER_CPU_STATE_INITIAL);
|
||||
assert( state == PER_CPU_STATE_INITIAL );
|
||||
}
|
||||
|
||||
TEST_END();
|
||||
} else {
|
||||
_SMP_barrier_Wait(&barrier, &barrier_state, cpu_count);
|
||||
_SMP_barrier_Wait( &barrier, &barrier_state, cpu_count );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void shutdown_handler(void *arg)
|
||||
static void shutdown_handler( void *arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
_SMP_Request_shutdown();
|
||||
_SMP_Fatal(SMP_FATAL_SHUTDOWN);
|
||||
_SMP_Fatal( SMP_FATAL_SHUTDOWN );
|
||||
}
|
||||
|
||||
static const Per_CPU_Job_context shutdown_context = {
|
||||
.handler = shutdown_handler
|
||||
};
|
||||
|
||||
static Per_CPU_Job shutdown_job = {
|
||||
.context = &shutdown_context
|
||||
};
|
||||
static Per_CPU_Job shutdown_job = { .context = &shutdown_context };
|
||||
|
||||
static rtems_status_code test_driver_init(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
(void) major;
|
||||
@@ -133,34 +131,34 @@ static rtems_status_code test_driver_init(
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
assert(rtems_configuration_get_maximum_processors() == MAX_CPUS);
|
||||
assert( rtems_configuration_get_maximum_processors() == MAX_CPUS );
|
||||
|
||||
main_cpu = self;
|
||||
other_cpu = (self + 1) % cpu_count;
|
||||
other_cpu = ( self + 1 ) % cpu_count;
|
||||
|
||||
for (cpu = 0; cpu < MAX_CPUS; ++cpu) {
|
||||
for ( cpu = 0; cpu < MAX_CPUS; ++cpu ) {
|
||||
const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
|
||||
Per_CPU_State state = _Per_CPU_Get_state(per_cpu);
|
||||
Per_CPU_State state = _Per_CPU_Get_state( per_cpu );
|
||||
|
||||
if (cpu == self) {
|
||||
assert(state == PER_CPU_STATE_INITIAL);
|
||||
} else if (cpu < cpu_count) {
|
||||
if ( cpu == self ) {
|
||||
assert( state == PER_CPU_STATE_INITIAL );
|
||||
} else if ( cpu < cpu_count ) {
|
||||
assert(
|
||||
state == PER_CPU_STATE_INITIAL
|
||||
|| state == PER_CPU_STATE_READY_TO_START_MULTITASKING
|
||||
state == PER_CPU_STATE_INITIAL ||
|
||||
state == PER_CPU_STATE_READY_TO_START_MULTITASKING
|
||||
);
|
||||
} else {
|
||||
assert(state == PER_CPU_STATE_INITIAL);
|
||||
assert( state == PER_CPU_STATE_INITIAL );
|
||||
}
|
||||
}
|
||||
|
||||
if (cpu_count > 1) {
|
||||
if ( cpu_count > 1 ) {
|
||||
Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( other_cpu );
|
||||
|
||||
_Per_CPU_Submit_job(per_cpu, &shutdown_job);
|
||||
_Per_CPU_Submit_job( per_cpu, &shutdown_job );
|
||||
} else {
|
||||
TEST_END();
|
||||
exit(0);
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
@@ -173,8 +171,7 @@ static rtems_status_code test_driver_init(
|
||||
{ .initialization_entry = test_driver_init }
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS MAX_CPUS
|
||||
|
||||
|
||||
@@ -47,61 +47,61 @@ static uint32_t main_cpu;
|
||||
|
||||
static SMP_barrier_Control barrier = SMP_BARRIER_CONTROL_INITIALIZER;
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
assert(0);
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
)
|
||||
{
|
||||
SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER;
|
||||
uint32_t self = rtems_scheduler_get_processor();
|
||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
uint32_t self = rtems_scheduler_get_processor();
|
||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
|
||||
assert(!always_set_to_false);
|
||||
assert( !always_set_to_false );
|
||||
|
||||
if ( source == RTEMS_FATAL_SOURCE_APPLICATION ) {
|
||||
uint32_t cpu;
|
||||
|
||||
assert(self == main_cpu);
|
||||
assert(code == 0xdeadbeef);
|
||||
assert( self == main_cpu );
|
||||
assert( code == 0xdeadbeef );
|
||||
|
||||
_SMP_Request_shutdown();
|
||||
_SMP_barrier_Wait(&barrier, &barrier_state, cpu_count);
|
||||
_SMP_barrier_Wait( &barrier, &barrier_state, cpu_count );
|
||||
|
||||
for (cpu = 0; cpu < cpu_count; ++cpu) {
|
||||
for ( cpu = 0; cpu < cpu_count; ++cpu ) {
|
||||
const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
|
||||
Per_CPU_State state = _Per_CPU_Get_state(per_cpu);
|
||||
Per_CPU_State state = _Per_CPU_Get_state( per_cpu );
|
||||
|
||||
assert(state == PER_CPU_STATE_SHUTDOWN);
|
||||
assert( state == PER_CPU_STATE_SHUTDOWN );
|
||||
}
|
||||
|
||||
for (cpu = cpu_count; cpu < MAX_CPUS; ++cpu) {
|
||||
for ( cpu = cpu_count; cpu < MAX_CPUS; ++cpu ) {
|
||||
const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
|
||||
Per_CPU_State state = _Per_CPU_Get_state(per_cpu);
|
||||
Per_CPU_State state = _Per_CPU_Get_state( per_cpu );
|
||||
|
||||
assert(state == PER_CPU_STATE_INITIAL);
|
||||
assert( state == PER_CPU_STATE_INITIAL );
|
||||
}
|
||||
|
||||
TEST_END();
|
||||
} else if ( source == RTEMS_FATAL_SOURCE_SMP ) {
|
||||
assert(self != main_cpu);
|
||||
assert(code == SMP_FATAL_SHUTDOWN_RESPONSE);
|
||||
_SMP_barrier_Wait(&barrier, &barrier_state, cpu_count);
|
||||
_SMP_barrier_Wait(&barrier, &barrier_state, cpu_count);
|
||||
assert( self != main_cpu );
|
||||
assert( code == SMP_FATAL_SHUTDOWN_RESPONSE );
|
||||
_SMP_barrier_Wait( &barrier, &barrier_state, cpu_count );
|
||||
_SMP_barrier_Wait( &barrier, &barrier_state, cpu_count );
|
||||
}
|
||||
}
|
||||
|
||||
static rtems_status_code test_driver_init(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
(void) major;
|
||||
@@ -114,31 +114,31 @@ static rtems_status_code test_driver_init(
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
assert(rtems_configuration_get_maximum_processors() == MAX_CPUS);
|
||||
assert( rtems_configuration_get_maximum_processors() == MAX_CPUS );
|
||||
|
||||
main_cpu = self;
|
||||
|
||||
for (cpu = 0; cpu < MAX_CPUS; ++cpu) {
|
||||
for ( cpu = 0; cpu < MAX_CPUS; ++cpu ) {
|
||||
const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
|
||||
Per_CPU_State state = _Per_CPU_Get_state(per_cpu);
|
||||
Per_CPU_State state = _Per_CPU_Get_state( per_cpu );
|
||||
|
||||
if (cpu == self) {
|
||||
assert(state == PER_CPU_STATE_INITIAL);
|
||||
} else if (cpu < cpu_count) {
|
||||
if ( cpu == self ) {
|
||||
assert( state == PER_CPU_STATE_INITIAL );
|
||||
} else if ( cpu < cpu_count ) {
|
||||
assert(
|
||||
state == PER_CPU_STATE_INITIAL
|
||||
|| state == PER_CPU_STATE_READY_TO_START_MULTITASKING
|
||||
state == PER_CPU_STATE_INITIAL ||
|
||||
state == PER_CPU_STATE_READY_TO_START_MULTITASKING
|
||||
);
|
||||
} else {
|
||||
assert(state == PER_CPU_STATE_INITIAL);
|
||||
assert( state == PER_CPU_STATE_INITIAL );
|
||||
}
|
||||
}
|
||||
|
||||
if (cpu_count > 1) {
|
||||
rtems_fatal(RTEMS_FATAL_SOURCE_APPLICATION, 0xdeadbeef);
|
||||
if ( cpu_count > 1 ) {
|
||||
rtems_fatal( RTEMS_FATAL_SOURCE_APPLICATION, 0xdeadbeef );
|
||||
} else {
|
||||
TEST_END();
|
||||
exit(0);
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
@@ -151,8 +151,7 @@ static rtems_status_code test_driver_init(
|
||||
{ .initialization_entry = test_driver_init }
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS MAX_CPUS
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ static void Init( rtems_task_argument arg )
|
||||
TEST_BEGIN();
|
||||
|
||||
sc = rtems_semaphore_create(
|
||||
rtems_build_name('M', 'R', 'S', 'P'),
|
||||
rtems_build_name( 'M', 'R', 'S', 'P' ),
|
||||
1,
|
||||
RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY |
|
||||
RTEMS_MULTIPROCESSOR_RESOURCE_SHARING,
|
||||
@@ -46,10 +46,7 @@ static void Init( rtems_task_argument arg )
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_timer_create(
|
||||
rtems_build_name( 'E', 'V', 'I', 'L' ),
|
||||
&timer_id
|
||||
);
|
||||
sc = rtems_timer_create( rtems_build_name( 'E', 'V', 'I', 'L' ), &timer_id );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_semaphore_obtain( sem_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
|
||||
@@ -64,14 +61,13 @@ static void Init( rtems_task_argument arg )
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
)
|
||||
{
|
||||
if (
|
||||
source == INTERNAL_ERROR_CORE
|
||||
&& !always_set_to_false
|
||||
&& code == INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE
|
||||
source == INTERNAL_ERROR_CORE && !always_set_to_false &&
|
||||
code == INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE
|
||||
) {
|
||||
TEST_END();
|
||||
}
|
||||
@@ -81,11 +77,10 @@ static void fatal_extension(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 1
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 1
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
@@ -39,31 +39,30 @@
|
||||
|
||||
const char rtems_test_name[] = "SMPFATAL 4";
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
assert(0);
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
)
|
||||
{
|
||||
TEST_BEGIN();
|
||||
|
||||
if (
|
||||
source == RTEMS_FATAL_SOURCE_SMP
|
||||
&& !always_set_to_false
|
||||
&& code == SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER
|
||||
source == RTEMS_FATAL_SOURCE_SMP && !always_set_to_false &&
|
||||
code == SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER
|
||||
) {
|
||||
rtems_status_code sc;
|
||||
rtems_id id;
|
||||
rtems_id id;
|
||||
|
||||
sc = rtems_scheduler_ident_by_processor(0, &id);
|
||||
assert(sc == RTEMS_INCORRECT_STATE);
|
||||
sc = rtems_scheduler_ident_by_processor( 0, &id );
|
||||
assert( sc == RTEMS_INCORRECT_STATE );
|
||||
|
||||
TEST_END();
|
||||
}
|
||||
@@ -73,8 +72,7 @@ static void fatal_extension(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES
|
||||
|
||||
|
||||
@@ -39,25 +39,24 @@
|
||||
|
||||
const char rtems_test_name[] = "SMPFATAL 5";
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
assert(0);
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
)
|
||||
{
|
||||
TEST_BEGIN();
|
||||
|
||||
if (
|
||||
source == RTEMS_FATAL_SOURCE_SMP
|
||||
&& !always_set_to_false
|
||||
&& code == SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT
|
||||
source == RTEMS_FATAL_SOURCE_SMP && !always_set_to_false &&
|
||||
code == SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT
|
||||
) {
|
||||
TEST_END();
|
||||
}
|
||||
@@ -67,8 +66,7 @@ static void fatal_extension(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
/* Lets see when the first RTEMS system hits this limit */
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 64
|
||||
@@ -77,23 +75,23 @@ static void fatal_extension(
|
||||
|
||||
#include <rtems/scheduler.h>
|
||||
|
||||
RTEMS_SCHEDULER_SIMPLE_SMP(a);
|
||||
RTEMS_SCHEDULER_SIMPLE_SMP( a );
|
||||
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_SIMPLE_SMP(a, rtems_build_name('S', 'I', 'M', 'P'))
|
||||
RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( a, rtems_build_name( 'S', 'I', 'M', 'P' ) )
|
||||
|
||||
#define ASSIGN \
|
||||
RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY)
|
||||
RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY )
|
||||
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, ASSIGN, \
|
||||
ASSIGN
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
const char rtems_test_name[] = "SMPFATAL 6";
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -43,21 +43,20 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
rtems_interrupt_local_disable(level);
|
||||
rtems_interrupt_local_disable( level );
|
||||
(void) level;
|
||||
rtems_task_wake_after(1);
|
||||
rtems_task_wake_after( 1 );
|
||||
}
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
)
|
||||
{
|
||||
if (
|
||||
source == INTERNAL_ERROR_CORE
|
||||
&& !always_set_to_false
|
||||
&& code == INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT
|
||||
source == INTERNAL_ERROR_CORE && !always_set_to_false &&
|
||||
code == INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT
|
||||
) {
|
||||
TEST_END();
|
||||
}
|
||||
@@ -67,8 +66,7 @@ static void fatal_extension(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 2
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ const char rtems_test_name[] = "SMPFATAL 8";
|
||||
* without BSP support.
|
||||
*/
|
||||
|
||||
void bsp_start_on_secondary_processor(struct Per_CPU_Control *cpu_self)
|
||||
void bsp_start_on_secondary_processor( struct Per_CPU_Control *cpu_self )
|
||||
{
|
||||
/* Provided to avoid multiple definitions of the CPU SMP support functions */
|
||||
(void) cpu_self;
|
||||
@@ -56,70 +56,69 @@ void bsp_start_on_secondary_processor(struct Per_CPU_Control *cpu_self)
|
||||
}
|
||||
|
||||
#if QORIQ_THREAD_COUNT > 1
|
||||
void qoriq_start_thread(Per_CPU_Control *cpu_self)
|
||||
void qoriq_start_thread( Per_CPU_Control *cpu_self )
|
||||
{
|
||||
/* Provided to avoid multiple definitions of the CPU SMP support functions */
|
||||
(void) cpu_self;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t _CPU_SMP_Initialize(void)
|
||||
uint32_t _CPU_SMP_Initialize( void )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool _CPU_SMP_Start_processor(uint32_t cpu_index)
|
||||
bool _CPU_SMP_Start_processor( uint32_t cpu_index )
|
||||
{
|
||||
(void) cpu_index;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
|
||||
void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
|
||||
{
|
||||
(void) cpu_count;
|
||||
|
||||
assert(0);
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
void _CPU_SMP_Prepare_start_multitasking(void)
|
||||
void _CPU_SMP_Prepare_start_multitasking( void )
|
||||
{
|
||||
assert(0);
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
#if defined(RTEMS_PARAVIRT) \
|
||||
|| (!defined(__leon__) && !defined(__PPC__) \
|
||||
&& !defined(__arm__) && !defined(__riscv))
|
||||
uint32_t _CPU_SMP_Get_current_processor(void)
|
||||
#if defined( RTEMS_PARAVIRT ) || \
|
||||
( !defined( __leon__ ) && !defined( __PPC__ ) && !defined( __arm__ ) && \
|
||||
!defined( __riscv ) )
|
||||
uint32_t _CPU_SMP_Get_current_processor( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
|
||||
void _CPU_SMP_Send_interrupt( uint32_t target_processor_index )
|
||||
{
|
||||
(void) target_processor_index;
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
assert(0);
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
)
|
||||
{
|
||||
TEST_BEGIN();
|
||||
|
||||
if (
|
||||
source == RTEMS_FATAL_SOURCE_SMP
|
||||
&& !always_set_to_false
|
||||
&& code == SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
|
||||
source == RTEMS_FATAL_SOURCE_SMP && !always_set_to_false &&
|
||||
code == SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
|
||||
) {
|
||||
TEST_END();
|
||||
}
|
||||
@@ -129,8 +128,7 @@ static void fatal_extension(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 2
|
||||
|
||||
@@ -138,14 +136,14 @@ static void fatal_extension(
|
||||
|
||||
#include <rtems/scheduler.h>
|
||||
|
||||
RTEMS_SCHEDULER_SIMPLE_SMP(a);
|
||||
RTEMS_SCHEDULER_SIMPLE_SMP( a );
|
||||
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_SIMPLE_SMP(a, rtems_build_name('S', 'I', 'M', 'P'))
|
||||
RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( a, rtems_build_name( 'S', 'I', 'M', 'P' ) )
|
||||
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
|
||||
RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY)
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \
|
||||
RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY )
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
PER_CPU_DATA_NEED_INITIALIZATION();
|
||||
|
||||
static PER_CPU_DATA_ITEM(int, i) = 123;
|
||||
static PER_CPU_DATA_ITEM( int, i ) = 123;
|
||||
|
||||
const char rtems_test_name[] = "SMPFATAL 9";
|
||||
|
||||
@@ -76,14 +76,13 @@ RTEMS_SYSINIT_ITEM(
|
||||
|
||||
static void fatal_extension(
|
||||
rtems_fatal_source source,
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
bool always_set_to_false,
|
||||
rtems_fatal_code code
|
||||
)
|
||||
{
|
||||
if (
|
||||
source == INTERNAL_ERROR_CORE
|
||||
&& !always_set_to_false
|
||||
&& code == INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA
|
||||
source == INTERNAL_ERROR_CORE && !always_set_to_false &&
|
||||
code == INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA
|
||||
) {
|
||||
TEST_END();
|
||||
}
|
||||
@@ -94,8 +93,7 @@ static void fatal_extension(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .fatal = fatal_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
{ .fatal = fatal_extension }, RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 2
|
||||
|
||||
|
||||
+115
-110
@@ -43,17 +43,17 @@ const char rtems_test_name[] = "SMPIPI 1";
|
||||
|
||||
typedef struct {
|
||||
uint32_t value;
|
||||
uint32_t cache_line_separation[31];
|
||||
uint32_t cache_line_separation[ 31 ];
|
||||
} test_counter;
|
||||
|
||||
typedef struct {
|
||||
test_counter counters[CPU_COUNT];
|
||||
uint32_t copy_counters[CPU_COUNT];
|
||||
test_counter counters[ CPU_COUNT ];
|
||||
uint32_t copy_counters[ CPU_COUNT ];
|
||||
SMP_barrier_Control barrier;
|
||||
SMP_barrier_State main_barrier_state;
|
||||
SMP_barrier_State worker_barrier_state;
|
||||
Per_CPU_Job jobs[CPU_COUNT][2];
|
||||
Per_CPU_Job sync_jobs[2];
|
||||
SMP_barrier_State main_barrier_state;
|
||||
SMP_barrier_State worker_barrier_state;
|
||||
Per_CPU_Job jobs[ CPU_COUNT ][ 2 ];
|
||||
Per_CPU_Job sync_jobs[ 2 ];
|
||||
} test_context;
|
||||
|
||||
static test_context test_instance = {
|
||||
@@ -62,24 +62,21 @@ static test_context test_instance = {
|
||||
.worker_barrier_state = SMP_BARRIER_STATE_INITIALIZER
|
||||
};
|
||||
|
||||
static void barrier(
|
||||
test_context *ctx,
|
||||
SMP_barrier_State *state
|
||||
)
|
||||
static void barrier( test_context *ctx, SMP_barrier_State *state )
|
||||
{
|
||||
_SMP_barrier_Wait(&ctx->barrier, state, 2);
|
||||
_SMP_barrier_Wait( &ctx->barrier, state, 2 );
|
||||
}
|
||||
|
||||
static void barrier_1_handler(void *arg)
|
||||
static void barrier_1_handler( void *arg )
|
||||
{
|
||||
test_context *ctx = arg;
|
||||
uint32_t cpu_index_self = _SMP_Get_current_processor();
|
||||
test_context *ctx = arg;
|
||||
uint32_t cpu_index_self = _SMP_Get_current_processor();
|
||||
SMP_barrier_State *bs = &ctx->worker_barrier_state;
|
||||
|
||||
++ctx->counters[cpu_index_self].value;
|
||||
++ctx->counters[ cpu_index_self ].value;
|
||||
|
||||
/* (D) */
|
||||
barrier(ctx, bs);
|
||||
barrier( ctx, bs );
|
||||
}
|
||||
|
||||
static const Per_CPU_Job_context barrier_1_job_context = {
|
||||
@@ -87,25 +84,25 @@ static const Per_CPU_Job_context barrier_1_job_context = {
|
||||
.arg = &test_instance
|
||||
};
|
||||
|
||||
static void barrier_0_handler(void *arg)
|
||||
static void barrier_0_handler( void *arg )
|
||||
{
|
||||
test_context *ctx = arg;
|
||||
uint32_t cpu_index_self = _SMP_Get_current_processor();
|
||||
test_context *ctx = arg;
|
||||
uint32_t cpu_index_self = _SMP_Get_current_processor();
|
||||
SMP_barrier_State *bs = &ctx->worker_barrier_state;
|
||||
|
||||
++ctx->counters[cpu_index_self].value;
|
||||
++ctx->counters[ cpu_index_self ].value;
|
||||
|
||||
/* (A) */
|
||||
barrier(ctx, bs);
|
||||
barrier( ctx, bs );
|
||||
|
||||
/* (B) */
|
||||
barrier(ctx, bs);
|
||||
barrier( ctx, bs );
|
||||
|
||||
/* (C) */
|
||||
barrier(ctx, bs);
|
||||
barrier( ctx, bs );
|
||||
|
||||
ctx->jobs[0][1].context = &barrier_1_job_context;
|
||||
_Per_CPU_Add_job(_Per_CPU_Get(), &ctx->jobs[0][1]);
|
||||
ctx->jobs[ 0 ][ 1 ].context = &barrier_1_job_context;
|
||||
_Per_CPU_Add_job( _Per_CPU_Get(), &ctx->jobs[ 0 ][ 1 ] );
|
||||
}
|
||||
|
||||
static const Per_CPU_Job_context barrier_0_job_context = {
|
||||
@@ -115,73 +112,79 @@ static const Per_CPU_Job_context barrier_0_job_context = {
|
||||
|
||||
static void test_send_message_while_processing_a_message(
|
||||
test_context *ctx,
|
||||
uint32_t cpu_index_self,
|
||||
uint32_t cpu_count
|
||||
uint32_t cpu_index_self,
|
||||
uint32_t cpu_count
|
||||
)
|
||||
{
|
||||
SMP_barrier_State *bs = &ctx->main_barrier_state;
|
||||
uint32_t cpu_index;
|
||||
rtems_status_code sc;
|
||||
cpu_set_t cpuset;
|
||||
uint32_t cpu_index;
|
||||
rtems_status_code sc;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
rtems_test_assert(cpu_index_self < CPU_SETSIZE);
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET((int) cpu_index_self, &cpuset);
|
||||
sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(cpuset), &cpuset);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( cpu_index_self < CPU_SETSIZE );
|
||||
CPU_ZERO( &cpuset );
|
||||
CPU_SET( (int) cpu_index_self, &cpuset );
|
||||
sc = rtems_task_set_affinity( RTEMS_SELF, sizeof( cpuset ), &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
|
||||
if (cpu_index != cpu_index_self) {
|
||||
for ( cpu_index = 0; cpu_index < cpu_count; ++cpu_index ) {
|
||||
if ( cpu_index != cpu_index_self ) {
|
||||
Per_CPU_Control *cpu_self;
|
||||
|
||||
ctx->jobs[0][0].context = &barrier_0_job_context;
|
||||
_Per_CPU_Submit_job(_Per_CPU_Get_by_index(cpu_index), &ctx->jobs[0][0]);
|
||||
ctx->jobs[ 0 ][ 0 ].context = &barrier_0_job_context;
|
||||
_Per_CPU_Submit_job(
|
||||
_Per_CPU_Get_by_index( cpu_index ),
|
||||
&ctx->jobs[ 0 ][ 0 ]
|
||||
);
|
||||
|
||||
/* (A) */
|
||||
barrier(ctx, bs);
|
||||
barrier( ctx, bs );
|
||||
|
||||
rtems_test_assert(ctx->counters[cpu_index].value == 1);
|
||||
rtems_test_assert( ctx->counters[ cpu_index ].value == 1 );
|
||||
_SMP_Send_message(
|
||||
_Per_CPU_Get_by_index(cpu_index),
|
||||
_Per_CPU_Get_by_index( cpu_index ),
|
||||
SMP_MESSAGE_PERFORM_JOBS
|
||||
);
|
||||
|
||||
/* (B) */
|
||||
barrier(ctx, bs);
|
||||
barrier( ctx, bs );
|
||||
|
||||
rtems_test_assert(ctx->counters[cpu_index].value == 1);
|
||||
rtems_test_assert( ctx->counters[ cpu_index ].value == 1 );
|
||||
|
||||
/* (C) */
|
||||
barrier(ctx, bs);
|
||||
barrier( ctx, bs );
|
||||
|
||||
/* (D) */
|
||||
barrier(ctx, bs);
|
||||
barrier( ctx, bs );
|
||||
|
||||
rtems_test_assert(ctx->counters[cpu_index].value == 2);
|
||||
rtems_test_assert( ctx->counters[ cpu_index ].value == 2 );
|
||||
|
||||
ctx->counters[cpu_index].value = 0;
|
||||
ctx->counters[ cpu_index ].value = 0;
|
||||
|
||||
/* Ensure that the second job is done and can be reused */
|
||||
cpu_self = _Thread_Dispatch_disable();
|
||||
_Per_CPU_Wait_for_job(_Per_CPU_Get_by_index(cpu_index), &ctx->jobs[0][1]);
|
||||
_Thread_Dispatch_enable(cpu_self);
|
||||
_Per_CPU_Wait_for_job(
|
||||
_Per_CPU_Get_by_index( cpu_index ),
|
||||
&ctx->jobs[ 0 ][ 1 ]
|
||||
);
|
||||
_Thread_Dispatch_enable( cpu_self );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void counter_handler(void *arg, size_t next_job)
|
||||
static void counter_handler( void *arg, size_t next_job )
|
||||
{
|
||||
test_context *ctx = arg;
|
||||
test_context *ctx = arg;
|
||||
Per_CPU_Control *cpu_self = _Per_CPU_Get();
|
||||
uint32_t cpu_index_self = _Per_CPU_Get_index(cpu_self);
|
||||
uint32_t cpu_index_self = _Per_CPU_Get_index( cpu_self );
|
||||
|
||||
++ctx->counters[cpu_index_self].value;
|
||||
_Per_CPU_Add_job(cpu_self, &ctx->jobs[cpu_index_self][next_job]);
|
||||
++ctx->counters[ cpu_index_self ].value;
|
||||
_Per_CPU_Add_job( cpu_self, &ctx->jobs[ cpu_index_self ][ next_job ] );
|
||||
}
|
||||
|
||||
static void counter_0_handler(void *arg)
|
||||
static void counter_0_handler( void *arg )
|
||||
{
|
||||
counter_handler(arg, 1);
|
||||
counter_handler( arg, 1 );
|
||||
}
|
||||
|
||||
static const Per_CPU_Job_context counter_0_job_context = {
|
||||
@@ -189,9 +192,9 @@ static const Per_CPU_Job_context counter_0_job_context = {
|
||||
.arg = &test_instance
|
||||
};
|
||||
|
||||
static void counter_1_handler(void *arg)
|
||||
static void counter_1_handler( void *arg )
|
||||
{
|
||||
counter_handler(arg, 0);
|
||||
counter_handler( arg, 0 );
|
||||
}
|
||||
|
||||
static const Per_CPU_Job_context counter_1_job_context = {
|
||||
@@ -199,22 +202,22 @@ static const Per_CPU_Job_context counter_1_job_context = {
|
||||
.arg = &test_instance
|
||||
};
|
||||
|
||||
static void sync_0_handler(void *arg)
|
||||
static void sync_0_handler( void *arg )
|
||||
{
|
||||
test_context *ctx = arg;
|
||||
|
||||
_Per_CPU_Submit_job(_Per_CPU_Get(), &ctx->sync_jobs[1]);
|
||||
_Per_CPU_Submit_job( _Per_CPU_Get(), &ctx->sync_jobs[ 1 ] );
|
||||
|
||||
/* (E) */
|
||||
barrier(ctx, &ctx->worker_barrier_state);
|
||||
barrier( ctx, &ctx->worker_barrier_state );
|
||||
}
|
||||
|
||||
static void sync_1_handler(void *arg)
|
||||
static void sync_1_handler( void *arg )
|
||||
{
|
||||
test_context *ctx = arg;
|
||||
|
||||
/* (F) */
|
||||
barrier(ctx, &ctx->worker_barrier_state);
|
||||
barrier( ctx, &ctx->worker_barrier_state );
|
||||
}
|
||||
|
||||
static const Per_CPU_Job_context sync_0_context = {
|
||||
@@ -227,13 +230,13 @@ static const Per_CPU_Job_context sync_1_context = {
|
||||
.arg = &test_instance
|
||||
};
|
||||
|
||||
static void wait_for_ipi_done(test_context *ctx, Per_CPU_Control *cpu)
|
||||
static void wait_for_ipi_done( test_context *ctx, Per_CPU_Control *cpu )
|
||||
{
|
||||
unsigned long done;
|
||||
|
||||
ctx->sync_jobs[0].context = &sync_0_context;
|
||||
ctx->sync_jobs[1].context = &sync_1_context;
|
||||
_Per_CPU_Submit_job(cpu, &ctx->sync_jobs[0]);
|
||||
ctx->sync_jobs[ 0 ].context = &sync_0_context;
|
||||
ctx->sync_jobs[ 1 ].context = &sync_1_context;
|
||||
_Per_CPU_Submit_job( cpu, &ctx->sync_jobs[ 0 ] );
|
||||
|
||||
/*
|
||||
* (E)
|
||||
@@ -243,98 +246,100 @@ static void wait_for_ipi_done(test_context *ctx, Per_CPU_Control *cpu)
|
||||
* will no longer make this IPI pending after this point. Let the
|
||||
* sync_0_handler() make it pending again to go to (F).
|
||||
*/
|
||||
barrier(ctx, &ctx->main_barrier_state);
|
||||
barrier( ctx, &ctx->main_barrier_state );
|
||||
|
||||
/* (F) */
|
||||
barrier(ctx, &ctx->main_barrier_state);
|
||||
barrier( ctx, &ctx->main_barrier_state );
|
||||
|
||||
/* Make sure that a potential counter_handler() finished */
|
||||
while (cpu->isr_nest_level != 0) {
|
||||
while ( cpu->isr_nest_level != 0 ) {
|
||||
RTEMS_COMPILER_MEMORY_BARRIER();
|
||||
}
|
||||
|
||||
done = _Atomic_Load_ulong( &ctx->sync_jobs[1].done, ATOMIC_ORDER_ACQUIRE );
|
||||
done = _Atomic_Load_ulong( &ctx->sync_jobs[ 1 ].done, ATOMIC_ORDER_ACQUIRE );
|
||||
rtems_test_assert( done == PER_CPU_JOB_DONE );
|
||||
}
|
||||
|
||||
static void test_send_message_flood(
|
||||
test_context *ctx,
|
||||
uint32_t cpu_count
|
||||
)
|
||||
static void test_send_message_flood( test_context *ctx, uint32_t cpu_count )
|
||||
{
|
||||
uint32_t cpu_index_self = rtems_scheduler_get_processor();
|
||||
uint32_t cpu_index;
|
||||
|
||||
for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
|
||||
Per_CPU_Control *cpu = _Per_CPU_Get_by_index(cpu_index);
|
||||
for ( cpu_index = 0; cpu_index < cpu_count; ++cpu_index ) {
|
||||
Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
|
||||
|
||||
ctx->jobs[cpu_index][0].context = &counter_0_job_context;
|
||||
ctx->jobs[cpu_index][1].context = &counter_1_job_context;
|
||||
_Per_CPU_Add_job(cpu, &ctx->jobs[cpu_index][0]);
|
||||
ctx->jobs[ cpu_index ][ 0 ].context = &counter_0_job_context;
|
||||
ctx->jobs[ cpu_index ][ 1 ].context = &counter_1_job_context;
|
||||
_Per_CPU_Add_job( cpu, &ctx->jobs[ cpu_index ][ 0 ] );
|
||||
}
|
||||
|
||||
for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
|
||||
for ( cpu_index = 0; cpu_index < cpu_count; ++cpu_index ) {
|
||||
Per_CPU_Control *cpu;
|
||||
uint32_t i;
|
||||
uint32_t i;
|
||||
|
||||
cpu = _Per_CPU_Get_by_index(cpu_index);
|
||||
cpu = _Per_CPU_Get_by_index( cpu_index );
|
||||
|
||||
for (i = 0; i < cpu_count; ++i) {
|
||||
if (i != cpu_index) {
|
||||
ctx->copy_counters[i] = ctx->counters[i].value;
|
||||
for ( i = 0; i < cpu_count; ++i ) {
|
||||
if ( i != cpu_index ) {
|
||||
ctx->copy_counters[ i ] = ctx->counters[ i ].value;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 100000; ++i) {
|
||||
_SMP_Send_message(cpu, SMP_MESSAGE_PERFORM_JOBS);
|
||||
for ( i = 0; i < 100000; ++i ) {
|
||||
_SMP_Send_message( cpu, SMP_MESSAGE_PERFORM_JOBS );
|
||||
}
|
||||
|
||||
if (cpu_index != cpu_index_self) {
|
||||
wait_for_ipi_done(ctx, cpu);
|
||||
if ( cpu_index != cpu_index_self ) {
|
||||
wait_for_ipi_done( ctx, cpu );
|
||||
}
|
||||
|
||||
for (i = 0; i < cpu_count; ++i) {
|
||||
if (i != cpu_index) {
|
||||
rtems_test_assert(ctx->copy_counters[i] == ctx->counters[i].value);
|
||||
for ( i = 0; i < cpu_count; ++i ) {
|
||||
if ( i != cpu_index ) {
|
||||
rtems_test_assert(
|
||||
ctx->copy_counters[ i ] == ctx->counters[ i ].value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
|
||||
for ( cpu_index = 0; cpu_index < cpu_count; ++cpu_index ) {
|
||||
rtems_test_assert(
|
||||
_Processor_mask_Is_set(_SMP_Get_online_processors(), cpu_index)
|
||||
_Processor_mask_Is_set( _SMP_Get_online_processors(), cpu_index )
|
||||
);
|
||||
|
||||
printf(
|
||||
"inter-processor interrupts for processor %"
|
||||
PRIu32 "%s: %" PRIu32 "\n",
|
||||
"inter-processor interrupts for processor %" PRIu32 "%s: %" PRIu32 "\n",
|
||||
cpu_index,
|
||||
cpu_index == cpu_index_self ? " (main)" : "",
|
||||
ctx->counters[cpu_index].value
|
||||
ctx->counters[ cpu_index ].value
|
||||
);
|
||||
}
|
||||
|
||||
for (; cpu_index < CPU_COUNT; ++cpu_index) {
|
||||
for ( ; cpu_index < CPU_COUNT; ++cpu_index ) {
|
||||
rtems_test_assert(
|
||||
!_Processor_mask_Is_set(_SMP_Get_online_processors(), cpu_index)
|
||||
!_Processor_mask_Is_set( _SMP_Get_online_processors(), cpu_index )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
test_context *ctx = &test_instance;
|
||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
uint32_t cpu_index_self;
|
||||
uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
uint32_t cpu_index_self;
|
||||
|
||||
for (cpu_index_self = 0; cpu_index_self < cpu_count; ++cpu_index_self) {
|
||||
test_send_message_while_processing_a_message(ctx, cpu_index_self, cpu_count);
|
||||
for ( cpu_index_self = 0; cpu_index_self < cpu_count; ++cpu_index_self ) {
|
||||
test_send_message_while_processing_a_message(
|
||||
ctx,
|
||||
cpu_index_self,
|
||||
cpu_count
|
||||
);
|
||||
}
|
||||
|
||||
test_send_message_flood(ctx, cpu_count);
|
||||
test_send_message_flood( ctx, cpu_count );
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -343,7 +348,7 @@ static void Init(rtems_task_argument arg)
|
||||
test();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
|
||||
|
||||
@@ -36,43 +36,43 @@
|
||||
#include <rtems/irq-extension.h>
|
||||
#include <rtems/malloc.h>
|
||||
|
||||
static void ensure_server_termination(void)
|
||||
static void ensure_server_termination( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_status_code sc;
|
||||
rtems_task_priority prio;
|
||||
rtems_id id;
|
||||
uint32_t cpu_self;
|
||||
uint32_t cpu_other;
|
||||
rtems_id id;
|
||||
uint32_t cpu_self;
|
||||
uint32_t cpu_other;
|
||||
|
||||
prio = 0;
|
||||
sc = rtems_task_set_priority(RTEMS_SELF, 124, &prio);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_task_set_priority( RTEMS_SELF, 124, &prio );
|
||||
T_rsc_success( sc );
|
||||
|
||||
cpu_self = rtems_scheduler_get_processor();
|
||||
cpu_other = (cpu_self + 1) % 2;
|
||||
cpu_other = ( cpu_self + 1 ) % 2;
|
||||
|
||||
sc = rtems_scheduler_ident_by_processor(cpu_other, &id);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_scheduler_ident_by_processor( cpu_other, &id );
|
||||
T_rsc_success( sc );
|
||||
|
||||
sc = rtems_task_set_scheduler(RTEMS_SELF, id, 124);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_task_set_scheduler( RTEMS_SELF, id, 124 );
|
||||
T_rsc_success( sc );
|
||||
|
||||
sc = rtems_scheduler_ident_by_processor(cpu_self, &id);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_scheduler_ident_by_processor( cpu_self, &id );
|
||||
T_rsc_success( sc );
|
||||
|
||||
sc = rtems_task_set_scheduler(RTEMS_SELF, id, prio);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_task_set_scheduler( RTEMS_SELF, id, prio );
|
||||
T_rsc_success( sc );
|
||||
}
|
||||
|
||||
T_TEST_CASE(InterruptServerSMPInitializeIncorrectState)
|
||||
T_TEST_CASE( InterruptServerSMPInitializeIncorrectState )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
uint32_t server_count;
|
||||
uint32_t server_count;
|
||||
|
||||
T_assert_eq_u32(rtems_scheduler_get_processor_maximum(), 2);
|
||||
T_assert_eq_u32( rtems_scheduler_get_processor_maximum(), 2 );
|
||||
|
||||
sc = rtems_interrupt_server_delete(0);
|
||||
T_rsc(sc, RTEMS_INVALID_ID);
|
||||
sc = rtems_interrupt_server_delete( 0 );
|
||||
T_rsc( sc, RTEMS_INVALID_ID );
|
||||
|
||||
server_count = 456;
|
||||
sc = rtems_interrupt_server_initialize(
|
||||
@@ -82,8 +82,8 @@ T_TEST_CASE(InterruptServerSMPInitializeIncorrectState)
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&server_count
|
||||
);
|
||||
T_rsc_success(sc);
|
||||
T_eq_u32(server_count, 2);
|
||||
T_rsc_success( sc );
|
||||
T_eq_u32( server_count, 2 );
|
||||
|
||||
server_count = 456;
|
||||
sc = rtems_interrupt_server_initialize(
|
||||
@@ -93,24 +93,24 @@ T_TEST_CASE(InterruptServerSMPInitializeIncorrectState)
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&server_count
|
||||
);
|
||||
T_rsc(sc, RTEMS_INCORRECT_STATE);
|
||||
T_eq_u32(server_count, 0);
|
||||
T_rsc( sc, RTEMS_INCORRECT_STATE );
|
||||
T_eq_u32( server_count, 0 );
|
||||
|
||||
sc = rtems_interrupt_server_delete(0);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_interrupt_server_delete( 0 );
|
||||
T_rsc_success( sc );
|
||||
ensure_server_termination();
|
||||
|
||||
sc = rtems_interrupt_server_delete(1);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_interrupt_server_delete( 1 );
|
||||
T_rsc_success( sc );
|
||||
ensure_server_termination();
|
||||
}
|
||||
|
||||
T_TEST_CASE(InterruptServerSMPInitializeInvalidPriority)
|
||||
T_TEST_CASE( InterruptServerSMPInitializeInvalidPriority )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
uint32_t server_count;
|
||||
uint32_t server_count;
|
||||
|
||||
T_assert_eq_u32(rtems_scheduler_get_processor_maximum(), 2);
|
||||
T_assert_eq_u32( rtems_scheduler_get_processor_maximum(), 2 );
|
||||
|
||||
server_count = 456;
|
||||
sc = rtems_interrupt_server_initialize(
|
||||
@@ -120,8 +120,8 @@ T_TEST_CASE(InterruptServerSMPInitializeInvalidPriority)
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&server_count
|
||||
);
|
||||
T_rsc(sc, RTEMS_INVALID_PRIORITY);
|
||||
T_eq_u32(server_count, 0);
|
||||
T_rsc( sc, RTEMS_INVALID_PRIORITY );
|
||||
T_eq_u32( server_count, 0 );
|
||||
|
||||
server_count = 456;
|
||||
sc = rtems_interrupt_server_initialize(
|
||||
@@ -131,27 +131,27 @@ T_TEST_CASE(InterruptServerSMPInitializeInvalidPriority)
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&server_count
|
||||
);
|
||||
T_rsc_success(sc);
|
||||
T_eq_u32(server_count, 2);
|
||||
T_rsc_success( sc );
|
||||
T_eq_u32( server_count, 2 );
|
||||
|
||||
sc = rtems_interrupt_server_delete(0);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_interrupt_server_delete( 0 );
|
||||
T_rsc_success( sc );
|
||||
ensure_server_termination();
|
||||
|
||||
sc = rtems_interrupt_server_delete(1);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_interrupt_server_delete( 1 );
|
||||
T_rsc_success( sc );
|
||||
ensure_server_termination();
|
||||
}
|
||||
|
||||
T_TEST_CASE(InterruptServerSMPInitializeNoMemory)
|
||||
T_TEST_CASE( InterruptServerSMPInitializeNoMemory )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
uint32_t server_count;
|
||||
void *greedy;
|
||||
uint32_t server_count;
|
||||
void *greedy;
|
||||
|
||||
T_assert_eq_u32(rtems_scheduler_get_processor_maximum(), 2);
|
||||
T_assert_eq_u32( rtems_scheduler_get_processor_maximum(), 2 );
|
||||
|
||||
greedy = rtems_heap_greedy_allocate(NULL, 0);
|
||||
greedy = rtems_heap_greedy_allocate( NULL, 0 );
|
||||
|
||||
server_count = 456;
|
||||
sc = rtems_interrupt_server_initialize(
|
||||
@@ -161,35 +161,35 @@ T_TEST_CASE(InterruptServerSMPInitializeNoMemory)
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&server_count
|
||||
);
|
||||
T_rsc(sc, RTEMS_NO_MEMORY);
|
||||
T_eq_u32(server_count, 1);
|
||||
T_rsc( sc, RTEMS_NO_MEMORY );
|
||||
T_eq_u32( server_count, 1 );
|
||||
|
||||
rtems_heap_greedy_free(greedy);
|
||||
rtems_heap_greedy_free( greedy );
|
||||
|
||||
sc = rtems_interrupt_server_delete(0);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_interrupt_server_delete( 0 );
|
||||
T_rsc_success( sc );
|
||||
ensure_server_termination();
|
||||
|
||||
sc = rtems_interrupt_server_delete(1);
|
||||
T_rsc(sc, RTEMS_INVALID_ID);
|
||||
sc = rtems_interrupt_server_delete( 1 );
|
||||
T_rsc( sc, RTEMS_INVALID_ID );
|
||||
}
|
||||
|
||||
T_TEST_CASE(InterruptServerSMPInitializeNoScheduler)
|
||||
T_TEST_CASE( InterruptServerSMPInitializeNoScheduler )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
uint32_t server_count;
|
||||
rtems_id scheduler_id;
|
||||
rtems_status_code sc;
|
||||
uint32_t server_count;
|
||||
rtems_id scheduler_id;
|
||||
rtems_task_priority prio;
|
||||
|
||||
T_assert_eq_u32(rtems_scheduler_get_processor_maximum(), 2);
|
||||
T_assert_eq_u32( rtems_scheduler_get_processor_maximum(), 2 );
|
||||
|
||||
scheduler_id = 0;
|
||||
sc = rtems_scheduler_ident_by_processor(1, &scheduler_id);
|
||||
T_rsc_success(sc);
|
||||
T_ne_u32(scheduler_id, 0);
|
||||
sc = rtems_scheduler_ident_by_processor( 1, &scheduler_id );
|
||||
T_rsc_success( sc );
|
||||
T_ne_u32( scheduler_id, 0 );
|
||||
|
||||
sc = rtems_scheduler_remove_processor(scheduler_id, 1);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_scheduler_remove_processor( scheduler_id, 1 );
|
||||
T_rsc_success( sc );
|
||||
|
||||
server_count = 456;
|
||||
sc = rtems_interrupt_server_initialize(
|
||||
@@ -199,31 +199,31 @@ T_TEST_CASE(InterruptServerSMPInitializeNoScheduler)
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&server_count
|
||||
);
|
||||
T_rsc_success(sc);
|
||||
T_eq_u32(server_count, 2);
|
||||
T_rsc_success( sc );
|
||||
T_eq_u32( server_count, 2 );
|
||||
|
||||
sc = rtems_interrupt_server_delete(0);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_interrupt_server_delete( 0 );
|
||||
T_rsc_success( sc );
|
||||
|
||||
sc = rtems_interrupt_server_delete(1);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_interrupt_server_delete( 1 );
|
||||
T_rsc_success( sc );
|
||||
|
||||
prio = 0;
|
||||
sc = rtems_task_set_priority(RTEMS_SELF, 124, &prio);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_task_set_priority( RTEMS_SELF, 124, &prio );
|
||||
T_rsc_success( sc );
|
||||
|
||||
sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_task_set_priority( RTEMS_SELF, prio, &prio );
|
||||
T_rsc_success( sc );
|
||||
|
||||
sc = rtems_scheduler_add_processor(scheduler_id, 1);
|
||||
T_rsc_success(sc);
|
||||
sc = rtems_scheduler_add_processor( scheduler_id, 1 );
|
||||
T_rsc_success( sc );
|
||||
}
|
||||
|
||||
const char rtems_test_name[] = "SMPIRQS 1";
|
||||
|
||||
static void Init(rtems_task_argument argument)
|
||||
static void Init( rtems_task_argument argument )
|
||||
{
|
||||
rtems_test_run(argument, TEST_STATE);
|
||||
rtems_test_run( argument, TEST_STATE );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -241,17 +241,20 @@ static void Init(rtems_task_argument argument)
|
||||
|
||||
#include <rtems/scheduler.h>
|
||||
|
||||
RTEMS_SCHEDULER_EDF_SMP(a);
|
||||
RTEMS_SCHEDULER_EDF_SMP( a );
|
||||
|
||||
RTEMS_SCHEDULER_EDF_SMP(b);
|
||||
RTEMS_SCHEDULER_EDF_SMP( b );
|
||||
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_EDF_SMP(a, rtems_build_name('A', ' ', ' ', ' ')), \
|
||||
RTEMS_SCHEDULER_TABLE_EDF_SMP(b, rtems_build_name('B', ' ', ' ', ' '))
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_EDF_SMP( a, rtems_build_name( 'A', ' ', ' ', ' ' ) ), \
|
||||
RTEMS_SCHEDULER_TABLE_EDF_SMP( \
|
||||
b, \
|
||||
rtems_build_name( 'B', ' ', ' ', ' ' ) \
|
||||
)
|
||||
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
|
||||
RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL)
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \
|
||||
RTEMS_SCHEDULER_ASSIGN( 1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL )
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@ const char rtems_test_name[] = "SMPMIGRATION 1";
|
||||
|
||||
#define CPU_COUNT 2
|
||||
|
||||
#define RUNNER_COUNT (CPU_COUNT + 1)
|
||||
#define RUNNER_COUNT ( CPU_COUNT + 1 )
|
||||
|
||||
#define PRIO_STOP 2
|
||||
|
||||
@@ -51,137 +51,143 @@ const char rtems_test_name[] = "SMPMIGRATION 1";
|
||||
|
||||
typedef struct {
|
||||
uint32_t counter;
|
||||
uint32_t unused_space_for_cache_line_alignment[7];
|
||||
uint32_t unused_space_for_cache_line_alignment[ 7 ];
|
||||
} cache_aligned_counter;
|
||||
|
||||
typedef struct {
|
||||
cache_aligned_counter tokens_per_cpu[CPU_COUNT];
|
||||
volatile cache_aligned_counter cycles_per_cpu[CPU_COUNT];
|
||||
cache_aligned_counter tokens_per_cpu[ CPU_COUNT ];
|
||||
volatile cache_aligned_counter cycles_per_cpu[ CPU_COUNT ];
|
||||
} test_counters;
|
||||
|
||||
typedef struct {
|
||||
test_counters counters[RUNNER_COUNT];
|
||||
test_counters counters[ RUNNER_COUNT ];
|
||||
volatile rtems_task_argument token;
|
||||
rtems_id runner_ids[RUNNER_COUNT];
|
||||
rtems_id runner_ids[ RUNNER_COUNT ];
|
||||
} test_context;
|
||||
|
||||
CPU_STRUCTURE_ALIGNMENT static test_context ctx_instance;
|
||||
|
||||
static void change_prio(rtems_id task, rtems_task_priority prio)
|
||||
static void change_prio( rtems_id task, rtems_task_priority prio )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_status_code sc;
|
||||
rtems_task_priority unused;
|
||||
|
||||
sc = rtems_task_set_priority(task, prio, &unused);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_priority( task, prio, &unused );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
static void runner(rtems_task_argument self)
|
||||
static void runner( rtems_task_argument self )
|
||||
{
|
||||
test_context *ctx = &ctx_instance;
|
||||
rtems_task_argument next = (self + 1) % RUNNER_COUNT;
|
||||
rtems_id next_runner = ctx->runner_ids[next];
|
||||
test_counters *counters = &ctx->counters[self];
|
||||
test_counters *next_counters = &ctx->counters[next];
|
||||
test_context *ctx = &ctx_instance;
|
||||
rtems_task_argument next = ( self + 1 ) % RUNNER_COUNT;
|
||||
rtems_id next_runner = ctx->runner_ids[ next ];
|
||||
test_counters *counters = &ctx->counters[ self ];
|
||||
test_counters *next_counters = &ctx->counters[ next ];
|
||||
|
||||
while (true) {
|
||||
while ( true ) {
|
||||
uint32_t current_cpu = rtems_scheduler_get_processor();
|
||||
|
||||
++counters->cycles_per_cpu[current_cpu].counter;
|
||||
++counters->cycles_per_cpu[ current_cpu ].counter;
|
||||
|
||||
if (ctx->token == self) {
|
||||
uint32_t other_cpu = (current_cpu + 1) % CPU_COUNT;
|
||||
if ( ctx->token == self ) {
|
||||
uint32_t other_cpu = ( current_cpu + 1 ) % CPU_COUNT;
|
||||
uint32_t snapshot;
|
||||
|
||||
++counters->tokens_per_cpu[current_cpu].counter;
|
||||
++counters->tokens_per_cpu[ current_cpu ].counter;
|
||||
|
||||
change_prio(next_runner, PRIO_HIGH);
|
||||
change_prio( next_runner, PRIO_HIGH );
|
||||
|
||||
snapshot = next_counters->cycles_per_cpu[other_cpu].counter;
|
||||
while (next_counters->cycles_per_cpu[other_cpu].counter == snapshot) {
|
||||
snapshot = next_counters->cycles_per_cpu[ other_cpu ].counter;
|
||||
while (
|
||||
next_counters->cycles_per_cpu[ other_cpu ].counter == snapshot
|
||||
) {
|
||||
/* Wait for other thread to resume execution */
|
||||
}
|
||||
|
||||
ctx->token = next;
|
||||
|
||||
change_prio(RTEMS_SELF, PRIO_NORMAL);
|
||||
change_prio( RTEMS_SELF, PRIO_NORMAL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void stopper(rtems_task_argument arg)
|
||||
static void stopper( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
while (true) {
|
||||
while ( true ) {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t abs_delta(uint32_t a, uint32_t b)
|
||||
static uint32_t abs_delta( uint32_t a, uint32_t b )
|
||||
{
|
||||
return a > b ? a - b : b - a;
|
||||
return a > b ? a - b : b - a;
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
test_context *ctx = &ctx_instance;
|
||||
rtems_status_code sc;
|
||||
test_context *ctx = &ctx_instance;
|
||||
rtems_status_code sc;
|
||||
rtems_task_argument runner_index;
|
||||
rtems_id stopper_id;
|
||||
uint32_t expected_tokens;
|
||||
uint32_t total_delta;
|
||||
uint64_t total_cycles;
|
||||
uint32_t average_cycles;
|
||||
rtems_id stopper_id;
|
||||
uint32_t expected_tokens;
|
||||
uint32_t total_delta;
|
||||
uint64_t total_cycles;
|
||||
uint32_t average_cycles;
|
||||
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('S', 'T', 'O', 'P'),
|
||||
rtems_build_name( 'S', 'T', 'O', 'P' ),
|
||||
PRIO_STOP,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&stopper_id
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
|
||||
for ( runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index ) {
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('R', 'U', 'N', (char) ('0' + runner_index)),
|
||||
rtems_build_name( 'R', 'U', 'N', (char) ( '0' + runner_index ) ),
|
||||
PRIO_HIGH + runner_index,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&ctx->runner_ids[runner_index]
|
||||
&ctx->runner_ids[ runner_index ]
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
|
||||
sc = rtems_task_start(ctx->runner_ids[runner_index], runner, runner_index);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
for ( runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index ) {
|
||||
sc = rtems_task_start(
|
||||
ctx->runner_ids[ runner_index ],
|
||||
runner,
|
||||
runner_index
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
sc = rtems_task_wake_after(10 * rtems_clock_get_ticks_per_second());
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_wake_after( 10 * rtems_clock_get_ticks_per_second() );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_start(stopper_id, stopper, 0);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_start( stopper_id, stopper, 0 );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
|
||||
sc = rtems_task_delete(ctx->runner_ids[runner_index]);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
for ( runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index ) {
|
||||
sc = rtems_task_delete( ctx->runner_ids[ runner_index ] );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
total_cycles = 0;
|
||||
for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
|
||||
const test_counters *counters = &ctx->counters[runner_index];
|
||||
size_t cpu;
|
||||
for ( runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index ) {
|
||||
const test_counters *counters = &ctx->counters[ runner_index ];
|
||||
size_t cpu;
|
||||
|
||||
for (cpu = 0; cpu < CPU_COUNT; ++cpu) {
|
||||
total_cycles += counters->cycles_per_cpu[cpu].counter;
|
||||
for ( cpu = 0; cpu < CPU_COUNT; ++cpu ) {
|
||||
total_cycles += counters->cycles_per_cpu[ cpu ].counter;
|
||||
}
|
||||
}
|
||||
average_cycles = (uint32_t) (total_cycles / (RUNNER_COUNT * CPU_COUNT));
|
||||
average_cycles = (uint32_t) ( total_cycles / ( RUNNER_COUNT * CPU_COUNT ) );
|
||||
|
||||
printf(
|
||||
"total cycles %" PRIu64 "\n"
|
||||
@@ -190,17 +196,17 @@ static void test(void)
|
||||
average_cycles
|
||||
);
|
||||
|
||||
for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
|
||||
const test_counters *counters = &ctx->counters[runner_index];
|
||||
size_t cpu;
|
||||
for ( runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index ) {
|
||||
const test_counters *counters = &ctx->counters[ runner_index ];
|
||||
size_t cpu;
|
||||
|
||||
printf("runner %" PRIuPTR "\n", runner_index);
|
||||
printf( "runner %" PRIuPTR "\n", runner_index );
|
||||
|
||||
for (cpu = 0; cpu < CPU_COUNT; ++cpu) {
|
||||
uint32_t tokens = counters->tokens_per_cpu[cpu].counter;
|
||||
uint32_t cycles = counters->cycles_per_cpu[cpu].counter;
|
||||
double cycle_deviation = ((double) cycles - average_cycles)
|
||||
/ average_cycles;
|
||||
for ( cpu = 0; cpu < CPU_COUNT; ++cpu ) {
|
||||
uint32_t tokens = counters->tokens_per_cpu[ cpu ].counter;
|
||||
uint32_t cycles = counters->cycles_per_cpu[ cpu ].counter;
|
||||
double cycle_deviation = ( (double) cycles - average_cycles ) /
|
||||
average_cycles;
|
||||
|
||||
printf(
|
||||
"\tcpu %zu tokens %" PRIu32 "\n"
|
||||
@@ -216,38 +222,38 @@ static void test(void)
|
||||
}
|
||||
}
|
||||
|
||||
expected_tokens = ctx->counters[0].tokens_per_cpu[0].counter;
|
||||
expected_tokens = ctx->counters[ 0 ].tokens_per_cpu[ 0 ].counter;
|
||||
total_delta = 0;
|
||||
for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
|
||||
test_counters *counters = &ctx->counters[runner_index];
|
||||
size_t cpu;
|
||||
for ( runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index ) {
|
||||
test_counters *counters = &ctx->counters[ runner_index ];
|
||||
size_t cpu;
|
||||
|
||||
for (cpu = 0; cpu < CPU_COUNT; ++cpu) {
|
||||
uint32_t tokens = counters->tokens_per_cpu[cpu].counter;
|
||||
uint32_t delta = abs_delta(tokens, expected_tokens);
|
||||
for ( cpu = 0; cpu < CPU_COUNT; ++cpu ) {
|
||||
uint32_t tokens = counters->tokens_per_cpu[ cpu ].counter;
|
||||
uint32_t delta = abs_delta( tokens, expected_tokens );
|
||||
|
||||
rtems_test_assert(delta <= 1);
|
||||
rtems_test_assert( delta <= 1 );
|
||||
|
||||
total_delta += delta;
|
||||
}
|
||||
}
|
||||
|
||||
rtems_test_assert(total_delta <= (RUNNER_COUNT * CPU_COUNT - 1));
|
||||
rtems_test_assert( total_delta <= ( RUNNER_COUNT * CPU_COUNT - 1 ) );
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
rtems_print_printer_fprintf_putc(&rtems_test_printer);
|
||||
rtems_print_printer_fprintf_putc( &rtems_test_printer );
|
||||
TEST_BEGIN();
|
||||
|
||||
if (rtems_scheduler_get_processor_maximum() >= 2) {
|
||||
if ( rtems_scheduler_get_processor_maximum() >= 2 ) {
|
||||
test();
|
||||
}
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -255,7 +261,7 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS CPU_COUNT
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS (2 + RUNNER_COUNT)
|
||||
#define CONFIGURE_MAXIMUM_TASKS ( 2 + RUNNER_COUNT )
|
||||
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -37,15 +37,18 @@ const char rtems_test_name[] = "SMPOPENMP 1";
|
||||
#define CPU_COUNT_MAX 32
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void work(void)
|
||||
static void work( void )
|
||||
{
|
||||
__asm__ volatile ("" : : : "memory");
|
||||
__asm__ volatile( ""
|
||||
:
|
||||
:
|
||||
: "memory" );
|
||||
}
|
||||
|
||||
static void barrier_bench(void)
|
||||
static void barrier_bench( void )
|
||||
{
|
||||
#pragma omp parallel
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
for ( int i = 0; i < 10000; ++i ) {
|
||||
work();
|
||||
#pragma omp barrier
|
||||
work();
|
||||
@@ -70,58 +73,58 @@ static void barrier_bench(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void parallel_bench(void)
|
||||
static void parallel_bench( void )
|
||||
{
|
||||
for (int i = 0; i < 20000; ++i) {
|
||||
for ( int i = 0; i < 20000; ++i ) {
|
||||
#pragma omp parallel
|
||||
work();
|
||||
}
|
||||
}
|
||||
|
||||
static void static_bench(void)
|
||||
static void static_bench( void )
|
||||
{
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
#pragma omp parallel for schedule (static)
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
for ( int i = 0; i < 1000; ++i ) {
|
||||
#pragma omp parallel for schedule( static )
|
||||
for ( int j = 0; j < 100; ++j ) {
|
||||
work();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void dynamic_bench(void)
|
||||
static void dynamic_bench( void )
|
||||
{
|
||||
#pragma omp parallel for schedule (dynamic)
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
for ( int i = 0; i < 100000; ++i ) {
|
||||
work();
|
||||
}
|
||||
}
|
||||
|
||||
static void guided_bench(void)
|
||||
static void guided_bench( void )
|
||||
{
|
||||
#pragma omp parallel for schedule (guided)
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
#pragma omp parallel for schedule( guided )
|
||||
for ( int i = 0; i < 100000; ++i ) {
|
||||
work();
|
||||
}
|
||||
}
|
||||
|
||||
static void runtime_bench(void)
|
||||
static void runtime_bench( void )
|
||||
{
|
||||
#pragma omp parallel for schedule (runtime)
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
#pragma omp parallel for schedule( runtime )
|
||||
for ( int i = 0; i < 100000; ++i ) {
|
||||
work();
|
||||
}
|
||||
}
|
||||
|
||||
static void single_bench(void)
|
||||
static void single_bench( void )
|
||||
{
|
||||
#pragma omp parallel
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
for ( int i = 0; i < 10000; ++i ) {
|
||||
#pragma omp single
|
||||
work();
|
||||
}
|
||||
}
|
||||
|
||||
static void all(void)
|
||||
static void all( void )
|
||||
{
|
||||
barrier_bench();
|
||||
parallel_bench();
|
||||
@@ -132,25 +135,25 @@ static void all(void)
|
||||
single_bench();
|
||||
}
|
||||
|
||||
static void do_bench(const char *name, void (*bench)(void), int n)
|
||||
static void do_bench( const char *name, void ( *bench )( void ), int n )
|
||||
{
|
||||
double start;
|
||||
double delta;
|
||||
|
||||
(*bench)();
|
||||
( *bench )();
|
||||
start = omp_get_wtime();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
(*bench)();
|
||||
for ( int i = 0; i < n; ++i ) {
|
||||
( *bench )();
|
||||
}
|
||||
delta = omp_get_wtime() - start;
|
||||
printf(",\n \"%s-bench\": %f", name, delta);
|
||||
printf( ",\n \"%s-bench\": %f", name, delta );
|
||||
}
|
||||
|
||||
static const char *test_sep = "";
|
||||
|
||||
static void microbench(int num_threads, int n)
|
||||
static void microbench( int num_threads, int n )
|
||||
{
|
||||
omp_set_num_threads(num_threads);
|
||||
omp_set_num_threads( num_threads );
|
||||
printf(
|
||||
"%s{\n"
|
||||
" \"num-threads\": %i,\n"
|
||||
@@ -160,30 +163,30 @@ static void microbench(int num_threads, int n)
|
||||
n
|
||||
);
|
||||
test_sep = ", ";
|
||||
do_bench("barrier", barrier_bench, n);
|
||||
do_bench("parallel", parallel_bench, n);
|
||||
do_bench("static", static_bench, n);
|
||||
do_bench("dynamic", dynamic_bench, n);
|
||||
do_bench("guided", guided_bench, n);
|
||||
do_bench("runtime", runtime_bench, n);
|
||||
do_bench("single", single_bench, n);
|
||||
printf("\n }");
|
||||
do_bench( "barrier", barrier_bench, n );
|
||||
do_bench( "parallel", parallel_bench, n );
|
||||
do_bench( "static", static_bench, n );
|
||||
do_bench( "dynamic", dynamic_bench, n );
|
||||
do_bench( "guided", guided_bench, n );
|
||||
do_bench( "runtime", runtime_bench, n );
|
||||
do_bench( "single", single_bench, n );
|
||||
printf( "\n }" );
|
||||
}
|
||||
|
||||
static int estimate_3s_runtime_with_one_proc(void)
|
||||
static int estimate_3s_runtime_with_one_proc( void )
|
||||
{
|
||||
double start;
|
||||
double delta;
|
||||
int n;
|
||||
int n;
|
||||
|
||||
omp_set_num_threads(1);
|
||||
omp_set_num_threads( 1 );
|
||||
all();
|
||||
start = omp_get_wtime();
|
||||
all();
|
||||
delta = omp_get_wtime() - start;
|
||||
|
||||
if (delta > 0.0 && delta <= 1.0) {
|
||||
n = (int) (3.0 / delta);
|
||||
if ( delta > 0.0 && delta <= 1.0 ) {
|
||||
n = (int) ( 3.0 / delta );
|
||||
} else {
|
||||
n = 1;
|
||||
}
|
||||
@@ -191,138 +194,138 @@ static int estimate_3s_runtime_with_one_proc(void)
|
||||
return n;
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
int num_procs;
|
||||
int n;
|
||||
|
||||
printf("*** BEGIN OF JSON DATA ***\n[\n ");
|
||||
printf( "*** BEGIN OF JSON DATA ***\n[\n " );
|
||||
|
||||
n = estimate_3s_runtime_with_one_proc();
|
||||
num_procs = omp_get_num_procs();
|
||||
omp_set_num_threads(num_procs);
|
||||
omp_set_num_threads( num_procs );
|
||||
|
||||
for (int i = 1; i <= num_procs; ++i) {
|
||||
microbench(i, n);
|
||||
for ( int i = 1; i <= num_procs; ++i ) {
|
||||
microbench( i, n );
|
||||
}
|
||||
|
||||
printf("\n]\n*** END OF JSON DATA ***\n");
|
||||
printf( "\n]\n*** END OF JSON DATA ***\n" );
|
||||
}
|
||||
|
||||
#ifdef __rtems__
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
rtems_status_code sc;
|
||||
cpu_set_t cpu_set;
|
||||
cpu_set_t cpu_set;
|
||||
|
||||
rtems_print_printer_fprintf_putc(&rtems_test_printer);
|
||||
rtems_print_printer_fprintf_putc( &rtems_test_printer );
|
||||
TEST_BEGIN();
|
||||
|
||||
CPU_ZERO(&cpu_set);
|
||||
CPU_SET(0, &cpu_set);
|
||||
CPU_ZERO( &cpu_set );
|
||||
CPU_SET( 0, &cpu_set );
|
||||
|
||||
sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(cpu_set), &cpu_set);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_affinity( RTEMS_SELF, sizeof( cpu_set ), &cpu_set );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
test();
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
pthread_mutex_t mtx;
|
||||
pthread_cond_t cnd;
|
||||
bool cpus_used[CPU_COUNT_MAX];
|
||||
pthread_cond_t cnd;
|
||||
bool cpus_used[ CPU_COUNT_MAX ];
|
||||
} test_context;
|
||||
|
||||
static test_context test_instance;
|
||||
|
||||
static uint32_t find_free_cpu(test_context *ctx)
|
||||
static uint32_t find_free_cpu( test_context *ctx )
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t n;
|
||||
|
||||
n = rtems_scheduler_get_processor_maximum();
|
||||
|
||||
pthread_mutex_lock(&ctx->mtx);
|
||||
pthread_mutex_lock( &ctx->mtx );
|
||||
|
||||
do {
|
||||
for (i = 1; i < n; ++i) {
|
||||
if (!ctx->cpus_used[i]) {
|
||||
ctx->cpus_used[i] = true;
|
||||
for ( i = 1; i < n; ++i ) {
|
||||
if ( !ctx->cpus_used[ i ] ) {
|
||||
ctx->cpus_used[ i ] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == n) {
|
||||
pthread_cond_wait(&ctx->cnd, &ctx->mtx);
|
||||
if ( i == n ) {
|
||||
pthread_cond_wait( &ctx->cnd, &ctx->mtx );
|
||||
}
|
||||
} while (i == n);
|
||||
} while ( i == n );
|
||||
|
||||
pthread_mutex_unlock(&ctx->mtx);
|
||||
pthread_mutex_unlock( &ctx->mtx );
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void begin_extension(Thread_Control *th)
|
||||
static void begin_extension( Thread_Control *th )
|
||||
{
|
||||
rtems_id th_id;
|
||||
|
||||
th_id = th->Object.id;
|
||||
|
||||
if (rtems_object_id_get_api(th_id) == OBJECTS_POSIX_API) {
|
||||
rtems_status_code sc;
|
||||
rtems_id sched_id;
|
||||
uint32_t cpu_index;
|
||||
cpu_set_t cpu_set;
|
||||
if ( rtems_object_id_get_api( th_id ) == OBJECTS_POSIX_API ) {
|
||||
rtems_status_code sc;
|
||||
rtems_id sched_id;
|
||||
uint32_t cpu_index;
|
||||
cpu_set_t cpu_set;
|
||||
rtems_task_priority prio;
|
||||
|
||||
cpu_index = find_free_cpu(&test_instance);
|
||||
cpu_index = find_free_cpu( &test_instance );
|
||||
|
||||
sc = rtems_scheduler_ident_by_processor(cpu_index, &sched_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_scheduler_ident_by_processor( cpu_index, &sched_id );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_set_priority(th_id, RTEMS_CURRENT_PRIORITY, &prio);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_priority( th_id, RTEMS_CURRENT_PRIORITY, &prio );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_set_scheduler(th_id, sched_id, prio);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_scheduler( th_id, sched_id, prio );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
CPU_ZERO(&cpu_set);
|
||||
CPU_SET((int) cpu_index, &cpu_set);
|
||||
CPU_ZERO( &cpu_set );
|
||||
CPU_SET( (int) cpu_index, &cpu_set );
|
||||
|
||||
sc = rtems_task_set_affinity(th_id, sizeof(cpu_set), &cpu_set);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_affinity( th_id, sizeof( cpu_set ), &cpu_set );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
}
|
||||
|
||||
static void terminate_extension(Thread_Control *th)
|
||||
static void terminate_extension( Thread_Control *th )
|
||||
{
|
||||
rtems_id th_id;
|
||||
|
||||
th_id = th->Object.id;
|
||||
|
||||
if (rtems_object_id_get_api(th_id) == OBJECTS_POSIX_API) {
|
||||
if ( rtems_object_id_get_api( th_id ) == OBJECTS_POSIX_API ) {
|
||||
rtems_status_code sc;
|
||||
cpu_set_t cpu_set;
|
||||
uint32_t cpu_index;
|
||||
test_context *ctx;
|
||||
cpu_set_t cpu_set;
|
||||
uint32_t cpu_index;
|
||||
test_context *ctx;
|
||||
|
||||
sc = rtems_task_get_affinity(th_id, sizeof(cpu_set), &cpu_set);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_get_affinity( th_id, sizeof( cpu_set ), &cpu_set );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
cpu_index = CPU_FFS(&cpu_set) - 1;
|
||||
cpu_index = CPU_FFS( &cpu_set ) - 1;
|
||||
|
||||
ctx = &test_instance;
|
||||
|
||||
pthread_mutex_lock(&ctx->mtx);
|
||||
rtems_test_assert(ctx->cpus_used[cpu_index]);
|
||||
ctx->cpus_used[cpu_index] = false;
|
||||
pthread_cond_broadcast(&ctx->cnd);
|
||||
pthread_mutex_unlock(&ctx->mtx);
|
||||
pthread_mutex_lock( &ctx->mtx );
|
||||
rtems_test_assert( ctx->cpus_used[ cpu_index ] );
|
||||
ctx->cpus_used[ cpu_index ] = false;
|
||||
pthread_cond_broadcast( &ctx->cnd );
|
||||
pthread_mutex_unlock( &ctx->mtx );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,12 +337,10 @@ static void terminate_extension(Thread_Control *th)
|
||||
#define CONFIGURE_UNLIMITED_OBJECTS
|
||||
#define CONFIGURE_UNIFIED_WORK_AREAS
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ \
|
||||
.thread_begin = begin_extension, \
|
||||
.thread_terminate = terminate_extension \
|
||||
}, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS \
|
||||
{ .thread_begin = begin_extension, \
|
||||
.thread_terminate = terminate_extension }, \
|
||||
RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
|
||||
|
||||
@@ -351,7 +352,7 @@ static void terminate_extension(Thread_Control *th)
|
||||
|
||||
#else /* __rtems__ */
|
||||
|
||||
int main(void)
|
||||
int main( void )
|
||||
{
|
||||
test();
|
||||
return 0;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <tmacros.h>
|
||||
#include <errno.h>
|
||||
@@ -41,19 +41,19 @@ const char rtems_test_name[] = "SMPPSXAFFINITY 1";
|
||||
|
||||
#define CPU_COUNT 4
|
||||
|
||||
pthread_t Init_id;
|
||||
pthread_t Init_id;
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
void *POSIX_Init(void *argument);
|
||||
void Validate_attrgetaffinity_errors(void);
|
||||
void Validate_attrsetaffinity_errors(void);
|
||||
void Validate_attr(void);
|
||||
void *POSIX_Init( void *argument );
|
||||
void Validate_attrgetaffinity_errors( void );
|
||||
void Validate_attrsetaffinity_errors( void );
|
||||
void Validate_attr( void );
|
||||
|
||||
void Validate_attrgetaffinity_errors(void)
|
||||
void Validate_attrgetaffinity_errors( void )
|
||||
{
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
|
||||
sc = pthread_attr_init( &attr );
|
||||
rtems_test_assert( sc == 0 );
|
||||
@@ -70,7 +70,7 @@ void Validate_attrgetaffinity_errors(void)
|
||||
|
||||
/* Verify pthread_attr_getaffinity_np validates cpusetsize */
|
||||
puts( "Init - pthread_attr_getaffinity_np - Invalid cpusetsize - EINVAL" );
|
||||
sc = pthread_attr_getaffinity_np( &attr, sizeof( cpuset ) * 2 , &cpuset );
|
||||
sc = pthread_attr_getaffinity_np( &attr, sizeof( cpuset ) * 2, &cpuset );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
|
||||
sc = pthread_attr_destroy( &attr );
|
||||
@@ -81,11 +81,11 @@ void Validate_attrgetaffinity_errors(void)
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
}
|
||||
|
||||
void Validate_attrsetaffinity_errors(void)
|
||||
void Validate_attrsetaffinity_errors( void )
|
||||
{
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
|
||||
sc = pthread_attr_init( &attr );
|
||||
rtems_test_assert( sc == 0 );
|
||||
@@ -102,26 +102,26 @@ void Validate_attrsetaffinity_errors(void)
|
||||
|
||||
/* Verify pthread_attr_setaffinity_np validates cpusetsize */
|
||||
puts( "Init - pthread_attr_setaffinity_np - Invalid cpusetsize - EINVAL" );
|
||||
sc = pthread_attr_setaffinity_np( &attr, sizeof( cpuset ) * 2 , &cpuset );
|
||||
sc = pthread_attr_setaffinity_np( &attr, sizeof( cpuset ) * 2, &cpuset );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
|
||||
sc = pthread_attr_destroy( &attr );
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "Init - pthread_attr_setaffinity_np - Not initialized attr - EINVAL" );
|
||||
sc = pthread_attr_setaffinity_np( &attr, sizeof( cpuset ), &cpuset );
|
||||
sc = pthread_attr_setaffinity_np( &attr, sizeof( cpuset ), &cpuset );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
}
|
||||
|
||||
void Validate_attr(void )
|
||||
void Validate_attr( void )
|
||||
{
|
||||
int sc;
|
||||
pthread_attr_t attr;
|
||||
uint32_t cpus;
|
||||
cpu_set_t cpuset1;
|
||||
cpu_set_t cpuset2;
|
||||
int i;
|
||||
int priority;
|
||||
int sc;
|
||||
pthread_attr_t attr;
|
||||
uint32_t cpus;
|
||||
cpu_set_t cpuset1;
|
||||
cpu_set_t cpuset2;
|
||||
int i;
|
||||
int priority;
|
||||
|
||||
sc = pthread_getattr_np( Init_id, &attr );
|
||||
rtems_test_assert( sc == 0 );
|
||||
@@ -129,7 +129,6 @@ void Validate_attr(void )
|
||||
priority = sched_get_priority_min( SCHED_FIFO );
|
||||
rtems_test_assert( priority != -1 );
|
||||
|
||||
|
||||
cpus = rtems_scheduler_get_processor_maximum();
|
||||
puts(
|
||||
"Init - Validate pthread_attr_setaffinity_np and "
|
||||
@@ -137,23 +136,21 @@ void Validate_attr(void )
|
||||
);
|
||||
|
||||
/* Set each cpu seperately in the affinity set */
|
||||
for ( i=0; i<cpus; i++ ){
|
||||
CPU_ZERO(&cpuset1);
|
||||
CPU_SET(i, &cpuset1);
|
||||
for ( i = 0; i < cpus; i++ ) {
|
||||
CPU_ZERO( &cpuset1 );
|
||||
CPU_SET( i, &cpuset1 );
|
||||
|
||||
sc = pthread_attr_setaffinity_np( &attr, sizeof(cpu_set_t), &cpuset1 );
|
||||
sc = pthread_attr_setaffinity_np( &attr, sizeof( cpu_set_t ), &cpuset1 );
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
sc = pthread_attr_getaffinity_np( &attr, sizeof(cpu_set_t), &cpuset2 );
|
||||
sc = pthread_attr_getaffinity_np( &attr, sizeof( cpu_set_t ), &cpuset2 );
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset1, &cpuset2) );
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset1, &cpuset2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
void *POSIX_Init(
|
||||
void *ignored
|
||||
)
|
||||
void *POSIX_Init( void *ignored )
|
||||
{
|
||||
(void) ignored;
|
||||
|
||||
@@ -167,7 +164,7 @@ void *POSIX_Init(
|
||||
Validate_attr();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
@@ -179,7 +176,7 @@ void *POSIX_Init(
|
||||
|
||||
#define CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define NUM_CPUS 4
|
||||
#define NUM_CPUS 4
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <tmacros.h>
|
||||
#include <errno.h>
|
||||
@@ -41,95 +41,94 @@
|
||||
|
||||
const char rtems_test_name[] = "SMPPSXAFFINITY 2";
|
||||
|
||||
pthread_t Init_id;
|
||||
pthread_t Med_id[NUM_CPUS-1];
|
||||
pthread_t Low_id[NUM_CPUS];
|
||||
pthread_t Init_id;
|
||||
pthread_t Med_id[ NUM_CPUS - 1 ];
|
||||
pthread_t Low_id[ NUM_CPUS ];
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
void *POSIX_Init(void *argument);
|
||||
void Validate_setaffinity_errors(void);
|
||||
void Validate_getaffinity_errors(void);
|
||||
void Validate_affinity(void);
|
||||
void *Thread_1(void *unused);
|
||||
void *POSIX_Init( void *argument );
|
||||
void Validate_setaffinity_errors( void );
|
||||
void Validate_getaffinity_errors( void );
|
||||
void Validate_affinity( void );
|
||||
void *Thread_1( void *unused );
|
||||
|
||||
void *Thread_1(void *unused)
|
||||
void *Thread_1( void *unused )
|
||||
{
|
||||
(void) unused;
|
||||
|
||||
while(1);
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
void Validate_setaffinity_errors(void)
|
||||
void Validate_setaffinity_errors( void )
|
||||
{
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
/* Verify pthread_setaffinity_np checks that more cpu's don't hurt. */
|
||||
CPU_FILL(&cpuset);
|
||||
CPU_FILL( &cpuset );
|
||||
puts( "Init - pthread_setaffinity_np - Lots of cpus - SUCCESS" );
|
||||
sc = pthread_setaffinity_np( Init_id, sizeof(cpu_set_t), &cpuset );
|
||||
sc = pthread_setaffinity_np( Init_id, sizeof( cpu_set_t ), &cpuset );
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
/* Verify pthread_setaffinity_np checks that at least one cpu is set */
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_ZERO( &cpuset );
|
||||
puts( "Init - pthread_setaffinity_np - no cpu - EINVAL" );
|
||||
sc = pthread_setaffinity_np( Init_id, sizeof(cpu_set_t), &cpuset );
|
||||
sc = pthread_setaffinity_np( Init_id, sizeof( cpu_set_t ), &cpuset );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
|
||||
/* Verify pthread_setaffinity_np checks that at thread id is valid */
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(0, &cpuset);
|
||||
CPU_ZERO( &cpuset );
|
||||
CPU_SET( 0, &cpuset );
|
||||
puts( "Init - pthread_setaffinity_np - Invalid thread - ESRCH" );
|
||||
sc = pthread_setaffinity_np( 999, sizeof(cpu_set_t), &cpuset );
|
||||
sc = pthread_setaffinity_np( 999, sizeof( cpu_set_t ), &cpuset );
|
||||
rtems_test_assert( sc == ESRCH );
|
||||
|
||||
/* Verify pthread_setaffinity_np validates cpusetsize */
|
||||
puts( "Init - pthread_setaffinity_np - Invalid cpusetsize - EINVAL" );
|
||||
sc = pthread_setaffinity_np( Init_id, 1, &cpuset );
|
||||
sc = pthread_setaffinity_np( Init_id, 1, &cpuset );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
|
||||
/* Verify pthread_setaffinity_np validates cpuset */
|
||||
puts( "Init - pthread_setaffinity_np - Invalid cpuset - EFAULT" );
|
||||
sc = pthread_setaffinity_np( Init_id, sizeof(cpu_set_t), NULL );
|
||||
sc = pthread_setaffinity_np( Init_id, sizeof( cpu_set_t ), NULL );
|
||||
rtems_test_assert( sc == EFAULT );
|
||||
}
|
||||
|
||||
void Validate_getaffinity_errors(void)
|
||||
void Validate_getaffinity_errors( void )
|
||||
{
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
int sc;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
/* Verify pthread_getaffinity_np checks that at thread id is valid */
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(0, &cpuset);
|
||||
CPU_ZERO( &cpuset );
|
||||
CPU_SET( 0, &cpuset );
|
||||
puts( "Init - pthread_getaffinity_np - Invalid thread - ESRCH" );
|
||||
sc = pthread_getaffinity_np( 999, sizeof(cpu_set_t), &cpuset );
|
||||
sc = pthread_getaffinity_np( 999, sizeof( cpu_set_t ), &cpuset );
|
||||
rtems_test_assert( sc == ESRCH );
|
||||
|
||||
/* Verify pthread_getaffinity_np validates cpusetsize */
|
||||
puts( "Init - pthread_getaffinity_np - Invalid cpusetsize - EINVAL" );
|
||||
sc = pthread_getaffinity_np( Init_id, 1, &cpuset );
|
||||
sc = pthread_getaffinity_np( Init_id, 1, &cpuset );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
|
||||
/* Verify pthread_getaffinity_np validates cpuset */
|
||||
puts("Init - pthread_getaffinity_np - Invalid cpuset - EFAULT");
|
||||
sc = pthread_getaffinity_np( Init_id, sizeof(cpu_set_t), NULL );
|
||||
puts( "Init - pthread_getaffinity_np - Invalid cpuset - EFAULT" );
|
||||
sc = pthread_getaffinity_np( Init_id, sizeof( cpu_set_t ), NULL );
|
||||
rtems_test_assert( sc == EFAULT );
|
||||
}
|
||||
|
||||
void Validate_affinity(void )
|
||||
void Validate_affinity( void )
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
cpu_set_t cpuset0;
|
||||
cpu_set_t cpuset1;
|
||||
cpu_set_t cpuset2;
|
||||
int i;
|
||||
int sc;
|
||||
int cpu_count;
|
||||
struct sched_param param;
|
||||
pthread_attr_t attr;
|
||||
cpu_set_t cpuset0;
|
||||
cpu_set_t cpuset1;
|
||||
cpu_set_t cpuset2;
|
||||
int i;
|
||||
int sc;
|
||||
int cpu_count;
|
||||
struct sched_param param;
|
||||
|
||||
|
||||
puts( "Init - Set Init priority to high");
|
||||
puts( "Init - Set Init priority to high" );
|
||||
sc = pthread_getattr_np( Init_id, &attr );
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
@@ -142,86 +141,88 @@ void Validate_affinity(void )
|
||||
sc = pthread_setschedparam( Init_id, SCHED_FIFO, ¶m );
|
||||
rtems_test_assert( !sc );
|
||||
|
||||
sc = pthread_getaffinity_np( Init_id, sizeof(cpu_set_t), &cpuset0 );
|
||||
sc = pthread_getaffinity_np( Init_id, sizeof( cpu_set_t ), &cpuset0 );
|
||||
rtems_test_assert( !sc );
|
||||
|
||||
/* Get the number of processors that we are using. */
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
|
||||
/* Fill the remaining cpus with med priority tasks */
|
||||
puts( "Init - Create Medium priority tasks");
|
||||
for (i=0; i<(cpu_count-1); i++){
|
||||
sc = pthread_create( &Med_id[i], &attr, Thread_1, NULL );
|
||||
puts( "Init - Create Medium priority tasks" );
|
||||
for ( i = 0; i < ( cpu_count - 1 ); i++ ) {
|
||||
sc = pthread_create( &Med_id[ i ], &attr, Thread_1, NULL );
|
||||
rtems_test_assert( !sc );
|
||||
}
|
||||
|
||||
puts( "Init - Verify Medium priority tasks");
|
||||
for (i=0; i<(cpu_count-1); i++){
|
||||
sc = pthread_getaffinity_np( Med_id[i], sizeof(cpu_set_t), &cpuset2 );
|
||||
puts( "Init - Verify Medium priority tasks" );
|
||||
for ( i = 0; i < ( cpu_count - 1 ); i++ ) {
|
||||
sc = pthread_getaffinity_np( Med_id[ i ], sizeof( cpu_set_t ), &cpuset2 );
|
||||
rtems_test_assert( !sc );
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset0, &cpuset2) );
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset0, &cpuset2 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Create low priority thread for each remaining cpu with the affinity
|
||||
* set to only run on one cpu.
|
||||
*/
|
||||
puts( "Init - Create Low priority tasks");
|
||||
for (i=0; i<cpu_count; i++){
|
||||
CPU_ZERO(&cpuset1);
|
||||
CPU_SET(i, &cpuset1);
|
||||
puts( "Init - Create Low priority tasks" );
|
||||
for ( i = 0; i < cpu_count; i++ ) {
|
||||
CPU_ZERO( &cpuset1 );
|
||||
CPU_SET( i, &cpuset1 );
|
||||
|
||||
sc = pthread_attr_setaffinity_np( &attr, sizeof(cpu_set_t), &cpuset1 );
|
||||
sc = pthread_attr_setaffinity_np( &attr, sizeof( cpu_set_t ), &cpuset1 );
|
||||
rtems_test_assert( !sc );
|
||||
|
||||
sc = pthread_create( &Low_id[i], &attr, Thread_1, NULL );
|
||||
sc = pthread_create( &Low_id[ i ], &attr, Thread_1, NULL );
|
||||
rtems_test_assert( !sc );
|
||||
}
|
||||
|
||||
/* Verify affinity on low priority tasks */
|
||||
puts( "Init - Verify Low priority tasks");
|
||||
for (i=0; i<(cpu_count-1); i++){
|
||||
CPU_ZERO(&cpuset1);
|
||||
CPU_SET(i, &cpuset1);
|
||||
puts( "Init - Verify Low priority tasks" );
|
||||
for ( i = 0; i < ( cpu_count - 1 ); i++ ) {
|
||||
CPU_ZERO( &cpuset1 );
|
||||
CPU_SET( i, &cpuset1 );
|
||||
|
||||
sc = pthread_getaffinity_np( Low_id[i], sizeof(cpu_set_t), &cpuset2 );
|
||||
sc = pthread_getaffinity_np( Low_id[ i ], sizeof( cpu_set_t ), &cpuset2 );
|
||||
rtems_test_assert( !sc );
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset1, &cpuset2) );
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset1, &cpuset2 ) );
|
||||
}
|
||||
|
||||
/* Change the affinity for each low priority task */
|
||||
puts("Init - Change affinity on Low priority tasks");
|
||||
CPU_COPY(&cpuset0, &cpuset1);
|
||||
for (i=0; i<cpu_count; i++){
|
||||
|
||||
CPU_CLR(i, &cpuset1);
|
||||
sc = pthread_setaffinity_np( Low_id[i], sizeof(cpu_set_t), &cpuset1 );
|
||||
puts( "Init - Change affinity on Low priority tasks" );
|
||||
CPU_COPY( &cpuset0, &cpuset1 );
|
||||
for ( i = 0; i < cpu_count; i++ ) {
|
||||
CPU_CLR( i, &cpuset1 );
|
||||
sc = pthread_setaffinity_np( Low_id[ i ], sizeof( cpu_set_t ), &cpuset1 );
|
||||
|
||||
/* Verify no cpu's are now set in the cpuset */
|
||||
if (i== (cpu_count-1)) {
|
||||
if ( i == ( cpu_count - 1 ) ) {
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
sc = pthread_setaffinity_np( Low_id[i], sizeof(cpu_set_t), &cpuset0 );
|
||||
sc = pthread_setaffinity_np(
|
||||
Low_id[ i ],
|
||||
sizeof( cpu_set_t ),
|
||||
&cpuset0
|
||||
);
|
||||
}
|
||||
rtems_test_assert( !sc );
|
||||
}
|
||||
|
||||
puts("Init - Validate affinity on Low priority tasks");
|
||||
CPU_COPY(&cpuset0, &cpuset1);
|
||||
for (i=0; i<cpu_count; i++){
|
||||
CPU_CLR(i, &cpuset1);
|
||||
puts( "Init - Validate affinity on Low priority tasks" );
|
||||
CPU_COPY( &cpuset0, &cpuset1 );
|
||||
for ( i = 0; i < cpu_count; i++ ) {
|
||||
CPU_CLR( i, &cpuset1 );
|
||||
|
||||
sc = pthread_getaffinity_np( Low_id[i], sizeof(cpu_set_t), &cpuset2 );
|
||||
sc = pthread_getaffinity_np( Low_id[ i ], sizeof( cpu_set_t ), &cpuset2 );
|
||||
rtems_test_assert( !sc );
|
||||
if (i== (cpu_count-1))
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset0, &cpuset2) );
|
||||
else
|
||||
rtems_test_assert( CPU_EQUAL(&cpuset1, &cpuset2) );
|
||||
if ( i == ( cpu_count - 1 ) ) {
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset0, &cpuset2 ) );
|
||||
} else {
|
||||
rtems_test_assert( CPU_EQUAL( &cpuset1, &cpuset2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *POSIX_Init(
|
||||
void *ignored
|
||||
)
|
||||
void *POSIX_Init( void *ignored )
|
||||
{
|
||||
(void) ignored;
|
||||
|
||||
@@ -235,7 +236,7 @@ void *POSIX_Init(
|
||||
Validate_affinity();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
@@ -247,7 +248,7 @@ void *POSIX_Init(
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS NUM_CPUS
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS (NUM_CPUS*2)
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS ( NUM_CPUS * 2 )
|
||||
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||
|
||||
|
||||
@@ -39,123 +39,127 @@
|
||||
|
||||
const char rtems_test_name[] = "SMPPSXMUTEX 1";
|
||||
|
||||
#define SCHED_A rtems_build_name(' ', ' ', ' ', 'A')
|
||||
#define SCHED_A rtems_build_name( ' ', ' ', ' ', 'A' )
|
||||
|
||||
#define SCHED_B rtems_build_name(' ', ' ', ' ', 'B')
|
||||
#define SCHED_B rtems_build_name( ' ', ' ', ' ', 'B' )
|
||||
|
||||
typedef struct {
|
||||
pthread_t thread_b;
|
||||
pthread_t thread_b;
|
||||
pthread_mutexattr_t mtx_attr;
|
||||
pthread_mutex_t mtx_a;
|
||||
pthread_mutex_t mtx_b;
|
||||
pthread_mutex_t mtx_a;
|
||||
pthread_mutex_t mtx_b;
|
||||
} test_context;
|
||||
|
||||
static test_context test_instance;
|
||||
|
||||
static void *thread_b(void *arg)
|
||||
static void *thread_b( void *arg )
|
||||
{
|
||||
test_context *ctx;
|
||||
int prio_ceiling;
|
||||
int eno;
|
||||
int prio_ceiling;
|
||||
int eno;
|
||||
|
||||
ctx = arg;
|
||||
|
||||
rtems_test_assert(rtems_scheduler_get_processor() == 1);
|
||||
rtems_test_assert( rtems_scheduler_get_processor() == 1 );
|
||||
|
||||
eno = pthread_mutex_init(&ctx->mtx_b, &ctx->mtx_attr);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutex_init( &ctx->mtx_b, &ctx->mtx_attr );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_getprioceiling(&ctx->mtx_b, &prio_ceiling);
|
||||
rtems_test_assert(eno == 0);
|
||||
rtems_test_assert(prio_ceiling == 254);
|
||||
eno = pthread_mutex_getprioceiling( &ctx->mtx_b, &prio_ceiling );
|
||||
rtems_test_assert( eno == 0 );
|
||||
rtems_test_assert( prio_ceiling == 254 );
|
||||
|
||||
eno = pthread_mutex_lock(&ctx->mtx_b);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutex_lock( &ctx->mtx_b );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_unlock(&ctx->mtx_b);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutex_unlock( &ctx->mtx_b );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_destroy(&ctx->mtx_b);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutex_destroy( &ctx->mtx_b );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_getprioceiling(&ctx->mtx_a, &prio_ceiling);
|
||||
rtems_test_assert(eno == 0);
|
||||
rtems_test_assert(prio_ceiling == 126);
|
||||
eno = pthread_mutex_getprioceiling( &ctx->mtx_a, &prio_ceiling );
|
||||
rtems_test_assert( eno == 0 );
|
||||
rtems_test_assert( prio_ceiling == 126 );
|
||||
|
||||
eno = pthread_mutex_lock(&ctx->mtx_a);
|
||||
rtems_test_assert(eno == EINVAL);
|
||||
eno = pthread_mutex_lock( &ctx->mtx_a );
|
||||
rtems_test_assert( eno == EINVAL );
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void test(test_context *ctx)
|
||||
static void test( test_context *ctx )
|
||||
{
|
||||
uint32_t cpu_count;
|
||||
int prio_ceiling;
|
||||
int eno;
|
||||
int prio_ceiling;
|
||||
int eno;
|
||||
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
|
||||
rtems_test_assert(rtems_scheduler_get_processor() == 0);
|
||||
rtems_test_assert( rtems_scheduler_get_processor() == 0 );
|
||||
|
||||
eno = pthread_mutexattr_init(&ctx->mtx_attr);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutexattr_init( &ctx->mtx_attr );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutexattr_setprotocol(&ctx->mtx_attr, PTHREAD_PRIO_PROTECT);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutexattr_setprotocol( &ctx->mtx_attr, PTHREAD_PRIO_PROTECT );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_init(&ctx->mtx_a, &ctx->mtx_attr);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutex_init( &ctx->mtx_a, &ctx->mtx_attr );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_getprioceiling(&ctx->mtx_a, &prio_ceiling);
|
||||
rtems_test_assert(eno == 0);
|
||||
rtems_test_assert(prio_ceiling == 126);
|
||||
eno = pthread_mutex_getprioceiling( &ctx->mtx_a, &prio_ceiling );
|
||||
rtems_test_assert( eno == 0 );
|
||||
rtems_test_assert( prio_ceiling == 126 );
|
||||
|
||||
eno = pthread_mutex_lock(&ctx->mtx_a);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutex_lock( &ctx->mtx_a );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_unlock(&ctx->mtx_a);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutex_unlock( &ctx->mtx_a );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
if (cpu_count > 1) {
|
||||
rtems_id scheduler_a_id;
|
||||
rtems_id scheduler_b_id;
|
||||
rtems_status_code sc;
|
||||
if ( cpu_count > 1 ) {
|
||||
rtems_id scheduler_a_id;
|
||||
rtems_id scheduler_b_id;
|
||||
rtems_status_code sc;
|
||||
rtems_task_priority prio;
|
||||
void *exit_code;
|
||||
void *exit_code;
|
||||
|
||||
sc = rtems_scheduler_ident(SCHED_A, &scheduler_a_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_scheduler_ident( SCHED_A, &scheduler_a_id );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_scheduler_ident( SCHED_B, &scheduler_b_id );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_set_priority(pthread_self(), RTEMS_CURRENT_PRIORITY, &prio);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_priority(
|
||||
pthread_self(),
|
||||
RTEMS_CURRENT_PRIORITY,
|
||||
&prio
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id, prio);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_scheduler( pthread_self(), scheduler_b_id, prio );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
eno = pthread_create(&ctx->thread_b, NULL, thread_b, ctx);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_create( &ctx->thread_b, NULL, thread_b, ctx );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
exit_code = NULL;
|
||||
eno = pthread_join(ctx->thread_b, &exit_code);
|
||||
rtems_test_assert(eno == 0);
|
||||
rtems_test_assert(exit_code == ctx);
|
||||
eno = pthread_join( ctx->thread_b, &exit_code );
|
||||
rtems_test_assert( eno == 0 );
|
||||
rtems_test_assert( exit_code == ctx );
|
||||
|
||||
sc = rtems_task_set_scheduler(pthread_self(), scheduler_a_id, prio);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_scheduler( pthread_self(), scheduler_a_id, prio );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
eno = pthread_mutex_destroy(&ctx->mtx_a);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutex_destroy( &ctx->mtx_a );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutexattr_destroy(&ctx->mtx_attr);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_mutexattr_destroy( &ctx->mtx_attr );
|
||||
rtems_test_assert( eno == 0 );
|
||||
}
|
||||
|
||||
static void *POSIX_Init(void *arg)
|
||||
static void *POSIX_Init( void *arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -163,14 +167,14 @@ static void *POSIX_Init(void *arg)
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
rtems_resource_snapshot_take(&snapshot);
|
||||
rtems_resource_snapshot_take( &snapshot );
|
||||
|
||||
test(&test_instance);
|
||||
test( &test_instance );
|
||||
|
||||
rtems_test_assert(rtems_resource_snapshot_check(&snapshot));
|
||||
rtems_test_assert( rtems_resource_snapshot_check( &snapshot ) );
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -184,17 +188,17 @@ static void *POSIX_Init(void *arg)
|
||||
|
||||
#include <rtems/scheduler.h>
|
||||
|
||||
RTEMS_SCHEDULER_PRIORITY_SMP(a, 128);
|
||||
RTEMS_SCHEDULER_PRIORITY_SMP( a, 128 );
|
||||
|
||||
RTEMS_SCHEDULER_PRIORITY_SMP(b, 256);
|
||||
RTEMS_SCHEDULER_PRIORITY_SMP( b, 256 );
|
||||
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_PRIORITY_SMP(a, SCHED_A), \
|
||||
RTEMS_SCHEDULER_TABLE_PRIORITY_SMP(b, SCHED_B) \
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_PRIORITY_SMP( a, SCHED_A ), \
|
||||
RTEMS_SCHEDULER_TABLE_PRIORITY_SMP( b, SCHED_B )
|
||||
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
|
||||
RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL)
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \
|
||||
RTEMS_SCHEDULER_ASSIGN( 1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL )
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
|
||||
@@ -38,155 +38,149 @@ const char rtems_test_name[] = "SMPPSXSIGNAL 1";
|
||||
|
||||
#define TEST_SIGNAL SIGUSR1
|
||||
|
||||
typedef enum {
|
||||
SIG_READY,
|
||||
SIG_SENT,
|
||||
SIG_PROCESSED
|
||||
} test_state;
|
||||
typedef enum { SIG_READY, SIG_SENT, SIG_PROCESSED } test_state;
|
||||
|
||||
typedef struct {
|
||||
volatile test_state state;
|
||||
pthread_t consumer;
|
||||
pthread_t producer;
|
||||
uint32_t consumer_processor;
|
||||
uint32_t producer_processor;
|
||||
pthread_t consumer;
|
||||
pthread_t producer;
|
||||
uint32_t consumer_processor;
|
||||
uint32_t producer_processor;
|
||||
} test_context;
|
||||
|
||||
static void change_state(test_context *ctx, test_state new_state)
|
||||
static void change_state( test_context *ctx, test_state new_state )
|
||||
{
|
||||
ctx->state = new_state;
|
||||
}
|
||||
|
||||
static void wait_for_state(const test_context *ctx, test_state desired_state)
|
||||
static void wait_for_state( const test_context *ctx, test_state desired_state )
|
||||
{
|
||||
while ( ctx->state != desired_state ) {
|
||||
/* Wait */
|
||||
}
|
||||
}
|
||||
|
||||
static test_context ctx_instance = {
|
||||
.state = SIG_READY
|
||||
};
|
||||
static test_context ctx_instance = { .state = SIG_READY };
|
||||
|
||||
static void signal_handler(int signum)
|
||||
static void signal_handler( int signum )
|
||||
{
|
||||
(void) signum;
|
||||
|
||||
test_context *ctx = &ctx_instance;
|
||||
|
||||
switch (ctx->state) {
|
||||
switch ( ctx->state ) {
|
||||
case SIG_SENT:
|
||||
change_state(ctx, SIG_PROCESSED);
|
||||
change_state( ctx, SIG_PROCESSED );
|
||||
break;
|
||||
default:
|
||||
rtems_test_assert(0);
|
||||
rtems_test_assert( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
static void signal_send(test_context *ctx, test_state new_state)
|
||||
static void signal_send( test_context *ctx, test_state new_state )
|
||||
{
|
||||
int eno;
|
||||
|
||||
eno = pthread_kill(ctx->consumer, TEST_SIGNAL);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_kill( ctx->consumer, TEST_SIGNAL );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
change_state(ctx, new_state);
|
||||
change_state( ctx, new_state );
|
||||
}
|
||||
|
||||
static void check_consumer_processor(const test_context *ctx)
|
||||
static void check_consumer_processor( const test_context *ctx )
|
||||
{
|
||||
rtems_test_assert(
|
||||
ctx->consumer_processor == rtems_scheduler_get_processor()
|
||||
);
|
||||
}
|
||||
|
||||
static void check_producer_processor(const test_context *ctx)
|
||||
static void check_producer_processor( const test_context *ctx )
|
||||
{
|
||||
rtems_test_assert(
|
||||
ctx->producer_processor == rtems_scheduler_get_processor()
|
||||
);
|
||||
}
|
||||
|
||||
static void *producer(void *arg)
|
||||
static void *producer( void *arg )
|
||||
{
|
||||
test_context *ctx = arg;
|
||||
|
||||
ctx->producer_processor = rtems_scheduler_get_processor();
|
||||
|
||||
rtems_test_assert(ctx->consumer_processor != ctx->producer_processor);
|
||||
rtems_test_assert( ctx->consumer_processor != ctx->producer_processor );
|
||||
|
||||
wait_for_state(ctx, SIG_READY);
|
||||
signal_send(ctx, SIG_SENT);
|
||||
wait_for_state( ctx, SIG_READY );
|
||||
signal_send( ctx, SIG_SENT );
|
||||
|
||||
check_producer_processor(ctx);
|
||||
check_producer_processor( ctx );
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
test_context *ctx = &ctx_instance;
|
||||
test_context *ctx = &ctx_instance;
|
||||
struct sigaction new_action;
|
||||
sigset_t test_signal_set;
|
||||
int rv;
|
||||
pthread_attr_t attr;
|
||||
int eno;
|
||||
void *producer_status;
|
||||
sigset_t test_signal_set;
|
||||
int rv;
|
||||
pthread_attr_t attr;
|
||||
int eno;
|
||||
void *producer_status;
|
||||
|
||||
ctx->consumer = pthread_self();
|
||||
ctx->consumer_processor = rtems_scheduler_get_processor();
|
||||
|
||||
memset(&new_action, 0, sizeof(new_action));
|
||||
memset( &new_action, 0, sizeof( new_action ) );
|
||||
new_action.sa_handler = signal_handler;
|
||||
|
||||
rv = sigaction(TEST_SIGNAL, &new_action, NULL);
|
||||
rtems_test_assert(rv == 0);
|
||||
rv = sigaction( TEST_SIGNAL, &new_action, NULL );
|
||||
rtems_test_assert( rv == 0 );
|
||||
|
||||
rv = sigemptyset(&test_signal_set);
|
||||
rtems_test_assert(rv == 0);
|
||||
rv = sigemptyset( &test_signal_set );
|
||||
rtems_test_assert( rv == 0 );
|
||||
|
||||
rv = sigaddset(&test_signal_set, TEST_SIGNAL);
|
||||
rtems_test_assert(rv == 0);
|
||||
rv = sigaddset( &test_signal_set, TEST_SIGNAL );
|
||||
rtems_test_assert( rv == 0 );
|
||||
|
||||
eno = pthread_sigmask(SIG_UNBLOCK, &test_signal_set, NULL);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_sigmask( SIG_UNBLOCK, &test_signal_set, NULL );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_attr_init(&attr);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_attr_init( &attr );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_create(&ctx->producer, &attr, producer, ctx);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_create( &ctx->producer, &attr, producer, ctx );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_attr_destroy(&attr);
|
||||
rtems_test_assert(eno == 0);
|
||||
eno = pthread_attr_destroy( &attr );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
check_consumer_processor(ctx);
|
||||
check_consumer_processor( ctx );
|
||||
|
||||
wait_for_state(ctx, SIG_PROCESSED);
|
||||
wait_for_state( ctx, SIG_PROCESSED );
|
||||
|
||||
check_consumer_processor(ctx);
|
||||
check_consumer_processor( ctx );
|
||||
|
||||
producer_status = NULL;
|
||||
pthread_join(ctx->producer, &producer_status);
|
||||
rtems_test_assert(eno == 0);
|
||||
rtems_test_assert(producer_status == ctx);
|
||||
pthread_join( ctx->producer, &producer_status );
|
||||
rtems_test_assert( eno == 0 );
|
||||
rtems_test_assert( producer_status == ctx );
|
||||
}
|
||||
|
||||
static void *POSIX_Init(void *arg)
|
||||
static void *POSIX_Init( void *arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
if (rtems_scheduler_get_processor_maximum() >= 2) {
|
||||
if ( rtems_scheduler_get_processor_maximum() >= 2 ) {
|
||||
test();
|
||||
}
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
@@ -53,51 +53,51 @@ const char rtems_test_name[] = "SMPSCHEDAFFINITY 1";
|
||||
#define TASK_COUNT 5
|
||||
|
||||
struct task_data_t {
|
||||
rtems_id id;
|
||||
int expected_cpu;
|
||||
cpu_set_t cpuset;
|
||||
bool ran;
|
||||
int actual_cpu;
|
||||
rtems_id id;
|
||||
int expected_cpu;
|
||||
cpu_set_t cpuset;
|
||||
bool ran;
|
||||
int actual_cpu;
|
||||
};
|
||||
|
||||
static struct task_data_t task_data[NUM_CPUS] = {
|
||||
{0x0, 2, {{0x4}}, false, -1},
|
||||
{0x0, 0, {{0x1}}, false, -1},
|
||||
{0x0, 3, {{0x8}}, false, -1},
|
||||
{0x0, 1, {{0x2}}, false, -1}
|
||||
static struct task_data_t task_data[ NUM_CPUS ] = {
|
||||
{ 0x0, 2, { { 0x4 } }, false, -1 },
|
||||
{ 0x0, 0, { { 0x1 } }, false, -1 },
|
||||
{ 0x0, 3, { { 0x8 } }, false, -1 },
|
||||
{ 0x0, 1, { { 0x2 } }, false, -1 }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Spin loop to allow tasks to delay without yeilding the
|
||||
* processor.
|
||||
*/
|
||||
static void test_delay(int ticks)
|
||||
{
|
||||
static void test_delay( int ticks )
|
||||
{
|
||||
rtems_interval start, stop;
|
||||
start = rtems_clock_get_ticks_since_boot();
|
||||
do {
|
||||
stop = rtems_clock_get_ticks_since_boot();
|
||||
} while ( (stop - start) < ticks );
|
||||
} while ( ( stop - start ) < ticks );
|
||||
}
|
||||
|
||||
static void task(rtems_task_argument arg)
|
||||
static void task( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
uint32_t cpu;
|
||||
uint32_t cpu;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
cpu = rtems_scheduler_get_processor();
|
||||
|
||||
rtems_task_get_affinity( rtems_task_self(), sizeof(cpuset), &cpuset );
|
||||
rtems_task_get_affinity( rtems_task_self(), sizeof( cpuset ), &cpuset );
|
||||
|
||||
task_data[arg].ran = true;
|
||||
task_data[arg].actual_cpu = cpu;
|
||||
task_data[ arg ].ran = true;
|
||||
task_data[ arg ].actual_cpu = cpu;
|
||||
|
||||
rtems_task_exit();
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_task_argument i;
|
||||
@@ -106,60 +106,62 @@ static void test(void)
|
||||
|
||||
/* Get the number of processors that we are using. */
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
|
||||
size = sizeof(cpu_set_t);
|
||||
|
||||
size = sizeof( cpu_set_t );
|
||||
|
||||
/* Create and start tasks on each cpu with the appropriate affinity. */
|
||||
for (i = 0; i < NUM_CPUS; i++) {
|
||||
|
||||
/* Skip if this cpu doesn't exist, don't create task */
|
||||
if ( task_data[i].expected_cpu >= cpu_count ) {
|
||||
printf(
|
||||
"Skipping TA0%" PRIdrtems_task_argument
|
||||
" because on a core we do not have\n",
|
||||
i
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('T', 'A', '0', '0'+i),
|
||||
4,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_data[ i ].id
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
for ( i = 0; i < NUM_CPUS; i++ ) {
|
||||
/* Skip if this cpu doesn't exist, don't create task */
|
||||
if ( task_data[ i ].expected_cpu >= cpu_count ) {
|
||||
printf(
|
||||
"Set TA%" PRIdrtems_task_argument " affinity to cpu %d\n",
|
||||
i,
|
||||
task_data[i].expected_cpu
|
||||
"Skipping TA0%" PRIdrtems_task_argument
|
||||
" because on a core we do not have\n",
|
||||
i
|
||||
);
|
||||
sc = rtems_task_set_affinity( task_data[ i ].id, size, &task_data[i].cpuset );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf(
|
||||
"Start TA%" PRIdrtems_task_argument " on cpu %d\n",
|
||||
i,
|
||||
task_data[i].expected_cpu
|
||||
);
|
||||
sc = rtems_task_start( task_data[ i ].id, task, i );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name( 'T', 'A', '0', '0' + i ),
|
||||
4,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_data[ i ].id
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
printf(
|
||||
"Set TA%" PRIdrtems_task_argument " affinity to cpu %d\n",
|
||||
i,
|
||||
task_data[ i ].expected_cpu
|
||||
);
|
||||
sc = rtems_task_set_affinity(
|
||||
task_data[ i ].id,
|
||||
size,
|
||||
&task_data[ i ].cpuset
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
printf(
|
||||
"Start TA%" PRIdrtems_task_argument " on cpu %d\n",
|
||||
i,
|
||||
task_data[ i ].expected_cpu
|
||||
);
|
||||
sc = rtems_task_start( task_data[ i ].id, task, i );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
/* spin for 100 ticks */
|
||||
test_delay(100);
|
||||
|
||||
printf("Verify Tasks Ran\n");
|
||||
for (i = 0; i < NUM_CPUS; i++) {
|
||||
test_delay( 100 );
|
||||
|
||||
printf( "Verify Tasks Ran\n" );
|
||||
for ( i = 0; i < NUM_CPUS; i++ ) {
|
||||
/* Skip if this cpu doesn't exist, task doesn't exist */
|
||||
if ( task_data[i].expected_cpu >= cpu_count ) {
|
||||
if ( task_data[ i ].expected_cpu >= cpu_count ) {
|
||||
printf(
|
||||
"Skipping TA0%" PRIdrtems_task_argument
|
||||
" because on a core we do not have\n",
|
||||
" because on a core we do not have\n",
|
||||
i
|
||||
);
|
||||
continue;
|
||||
@@ -169,18 +171,20 @@ static void test(void)
|
||||
printf(
|
||||
"TA0%" PRIdrtems_task_argument ": ran=%d expected=%d actual=%d\n",
|
||||
i,
|
||||
task_data[i].ran,
|
||||
task_data[i].expected_cpu,
|
||||
task_data[i].actual_cpu
|
||||
task_data[ i ].ran,
|
||||
task_data[ i ].expected_cpu,
|
||||
task_data[ i ].actual_cpu
|
||||
);
|
||||
|
||||
/* Abort test if values are not as expected */
|
||||
rtems_test_assert( task_data[i].ran == true );
|
||||
rtems_test_assert( task_data[i].expected_cpu == task_data[i].actual_cpu );
|
||||
rtems_test_assert( task_data[ i ].ran == true );
|
||||
rtems_test_assert(
|
||||
task_data[ i ].expected_cpu == task_data[ i ].actual_cpu
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -189,7 +193,7 @@ static void Init(rtems_task_argument arg)
|
||||
test();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -199,11 +203,11 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS NUM_CPUS
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
|
||||
#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 8
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 8
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
@@ -46,61 +46,63 @@
|
||||
|
||||
const char rtems_test_name[] = "SMPSCHEDAFFINITY 2";
|
||||
|
||||
#define NUM_CPUS 2
|
||||
#define NUM_CPUS 2
|
||||
|
||||
struct task_data_t {
|
||||
rtems_id id;
|
||||
int expected_cpu;
|
||||
cpu_set_t cpuset;
|
||||
bool ran;
|
||||
int actual_cpu;
|
||||
rtems_id id;
|
||||
int expected_cpu;
|
||||
cpu_set_t cpuset;
|
||||
bool ran;
|
||||
int actual_cpu;
|
||||
};
|
||||
|
||||
struct task_data_t task_data = {
|
||||
0x0, 0, {{0x3}}, false, -1
|
||||
};
|
||||
struct task_data_t task_data = { 0x0, 0, { { 0x3 } }, false, -1 };
|
||||
|
||||
rtems_id task_sem;
|
||||
rtems_id task_sem;
|
||||
|
||||
static void task(rtems_task_argument arg);
|
||||
static void task( rtems_task_argument arg );
|
||||
static void task_verify( bool ran, bool change_affinity, int cpu );
|
||||
static void init_verify( int expect );
|
||||
static void init_verify( int expect );
|
||||
|
||||
static void test_delay(int ticks)
|
||||
{
|
||||
static void test_delay( int ticks )
|
||||
{
|
||||
rtems_interval start, stop;
|
||||
start = rtems_clock_get_ticks_since_boot();
|
||||
do {
|
||||
stop = rtems_clock_get_ticks_since_boot();
|
||||
} while ( (stop - start) < ticks );
|
||||
} while ( ( stop - start ) < ticks );
|
||||
}
|
||||
|
||||
static void task_verify( bool ran, bool change_affinity, int cpu )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
size_t size = sizeof(cpu_set_t);
|
||||
rtems_status_code sc;
|
||||
size_t size = sizeof( cpu_set_t );
|
||||
|
||||
/* Obtain the semaphore without blocking */
|
||||
while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
|
||||
while (
|
||||
rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 ) != RTEMS_SUCCESSFUL
|
||||
);
|
||||
|
||||
/* print the expected and actual values */
|
||||
printf( "TA01: expected=%d actual=%d ran=%d\n",
|
||||
task_data.expected_cpu,
|
||||
task_data.actual_cpu,
|
||||
task_data.ran
|
||||
);
|
||||
printf(
|
||||
"TA01: expected=%d actual=%d ran=%d\n",
|
||||
task_data.expected_cpu,
|
||||
task_data.actual_cpu,
|
||||
task_data.ran
|
||||
);
|
||||
|
||||
/* Verify expected results */
|
||||
rtems_test_assert( task_data.ran == ran );
|
||||
if (ran)
|
||||
if ( ran ) {
|
||||
rtems_test_assert( task_data.expected_cpu == task_data.actual_cpu );
|
||||
}
|
||||
|
||||
if (change_affinity) {
|
||||
printf("Set TA01 to cpu %d\n", cpu);
|
||||
CPU_ZERO(&task_data.cpuset);
|
||||
CPU_SET(cpu, &task_data.cpuset);
|
||||
if ( change_affinity ) {
|
||||
printf( "Set TA01 to cpu %d\n", cpu );
|
||||
CPU_ZERO( &task_data.cpuset );
|
||||
CPU_SET( cpu, &task_data.cpuset );
|
||||
sc = rtems_task_set_affinity( task_data.id, size, &task_data.cpuset );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
/* Reset the states */
|
||||
@@ -108,117 +110,114 @@ static void task_verify( bool ran, bool change_affinity, int cpu )
|
||||
task_data.expected_cpu = cpu;
|
||||
|
||||
/* Release the semaphore */
|
||||
rtems_semaphore_release(task_sem);
|
||||
test_delay(25);
|
||||
}
|
||||
rtems_semaphore_release( task_sem );
|
||||
test_delay( 25 );
|
||||
}
|
||||
|
||||
static void init_verify( int expect )
|
||||
static void init_verify( int expect )
|
||||
{
|
||||
int cpu;
|
||||
|
||||
|
||||
test_delay(20);
|
||||
test_delay( 20 );
|
||||
|
||||
cpu = rtems_scheduler_get_processor();
|
||||
printf( "Init: expected=%d actual=%d\n", expect, cpu);
|
||||
printf( "Init: expected=%d actual=%d\n", expect, cpu );
|
||||
rtems_test_assert( expect == cpu );
|
||||
}
|
||||
|
||||
static void task(rtems_task_argument arg)
|
||||
static void task( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
rtems_status_code sc;
|
||||
rtems_status_code sc;
|
||||
|
||||
/* Never block and continually get core id */
|
||||
while (true) {
|
||||
sc = rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0);
|
||||
if (sc == RTEMS_SUCCESSFUL) {
|
||||
while ( true ) {
|
||||
sc = rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 );
|
||||
if ( sc == RTEMS_SUCCESSFUL ) {
|
||||
task_data.actual_cpu = rtems_scheduler_get_processor();
|
||||
task_data.ran = true;
|
||||
rtems_semaphore_release(task_sem);
|
||||
test_delay(25);
|
||||
rtems_semaphore_release( task_sem );
|
||||
test_delay( 25 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
uint32_t cpu_count;
|
||||
rtems_id id_self;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
rtems_status_code sc;
|
||||
uint32_t cpu_count;
|
||||
rtems_id id_self;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
/* Get the number of processors that we are using. */
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
if (cpu_count < NUM_CPUS) {
|
||||
printf("Error: Test requires at least 2 cpus\n");
|
||||
if ( cpu_count < NUM_CPUS ) {
|
||||
printf( "Error: Test requires at least 2 cpus\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
id_self = rtems_task_self();
|
||||
|
||||
printf("Create Semaphore\n");
|
||||
sc = rtems_semaphore_create(
|
||||
rtems_build_name('S', 'E', 'M', '0'),
|
||||
|
||||
printf( "Create Semaphore\n" );
|
||||
sc = rtems_semaphore_create(
|
||||
rtems_build_name( 'S', 'E', 'M', '0' ),
|
||||
1,
|
||||
RTEMS_BINARY_SEMAPHORE |
|
||||
RTEMS_PRIORITY |
|
||||
RTEMS_PRIORITY_CEILING,
|
||||
RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
|
||||
0,
|
||||
&task_sem
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
printf("Create TA1\n");
|
||||
printf( "Create TA1\n" );
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('T', 'A', '0', '1'),
|
||||
rtems_build_name( 'T', 'A', '0', '1' ),
|
||||
4,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_data.id
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* TA1 should start on cpu 0, since init starts on core 1 */
|
||||
sc = rtems_task_start( task_data.id, task, 1 );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* Verify Init task is on cpu 1 */
|
||||
init_verify(1);
|
||||
init_verify( 1 );
|
||||
|
||||
/* Verify TA1 on cpu 0 and set the affinity to cpu 0 */
|
||||
task_verify( true, true, 0 );
|
||||
|
||||
|
||||
/* Verify Init task is on cpu 1 */
|
||||
init_verify(1);
|
||||
init_verify( 1 );
|
||||
|
||||
/* Verify TA1 on cpu 0 and change the affinity to cpu 1 */
|
||||
task_verify( true, true, 1 );
|
||||
|
||||
/* Verify Init task is on cpu 1 */
|
||||
init_verify(1);
|
||||
init_verify( 1 );
|
||||
|
||||
/* Verify TA1 did not run */
|
||||
task_verify( false, false, 1 );
|
||||
|
||||
/* Set affinity of Init to cpu 0 */
|
||||
printf("Set Affinity of init task to cpu 0\n");
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(0, &cpuset);
|
||||
sc = rtems_task_set_affinity( id_self, sizeof(cpuset), &cpuset );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
printf( "Set Affinity of init task to cpu 0\n" );
|
||||
CPU_ZERO( &cpuset );
|
||||
CPU_SET( 0, &cpuset );
|
||||
sc = rtems_task_set_affinity( id_self, sizeof( cpuset ), &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* Verify init task went to cpu 0 */
|
||||
test_delay(50);
|
||||
init_verify(0);
|
||||
test_delay( 50 );
|
||||
init_verify( 0 );
|
||||
|
||||
/* Verfiy TA1 is now running on cpu 1 */
|
||||
task_verify(true, false, 1);
|
||||
task_verify( true, false, 1 );
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -227,7 +226,7 @@ static void Init(rtems_task_argument arg)
|
||||
test();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -237,11 +236,11 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS NUM_CPUS
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS NUM_CPUS
|
||||
#define CONFIGURE_MAXIMUM_TASKS NUM_CPUS
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 4
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 4
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
|
||||
@@ -43,53 +43,52 @@ const char rtems_test_name[] = "SMPSCHEDAFFINITY 3";
|
||||
#define NUM_CPUS 4
|
||||
#define TASK_COUNT NUM_CPUS
|
||||
|
||||
static void test_delay(rtems_interval ticks)
|
||||
{
|
||||
static void test_delay( rtems_interval ticks )
|
||||
{
|
||||
rtems_interval start, stop;
|
||||
start = rtems_clock_get_ticks_since_boot();
|
||||
do {
|
||||
stop = rtems_clock_get_ticks_since_boot();
|
||||
} while ( (stop - start) < ticks );
|
||||
} while ( ( stop - start ) < ticks );
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_id id;
|
||||
uint32_t cpu_count;
|
||||
int cpu;
|
||||
int i;
|
||||
cpu_set_t cpuset;
|
||||
rtems_status_code sc;
|
||||
rtems_id id;
|
||||
uint32_t cpu_count;
|
||||
int cpu;
|
||||
int i;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
/* Get the number of processors that we are using. */
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
|
||||
|
||||
id = rtems_task_self();
|
||||
|
||||
/*
|
||||
* The Init task comes up on the maximum core so start at
|
||||
* that core and walk the affinity down to core 0.
|
||||
*/
|
||||
for( i=cpu_count-1; i >= 0; i--) {
|
||||
|
||||
for ( i = cpu_count - 1; i >= 0; i-- ) {
|
||||
/* Move the affinity to the current core - 1 */
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(i, &cpuset);
|
||||
printf("Set Affinity for cpu %d\n", i);
|
||||
sc = rtems_task_set_affinity( id, sizeof(cpuset), &cpuset );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
CPU_ZERO( &cpuset );
|
||||
CPU_SET( i, &cpuset );
|
||||
printf( "Set Affinity for cpu %d\n", i );
|
||||
sc = rtems_task_set_affinity( id, sizeof( cpuset ), &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* Wait 100 clock ticks */
|
||||
test_delay(100);
|
||||
test_delay( 100 );
|
||||
|
||||
/* Check the cpu the Init task is running on */
|
||||
cpu = rtems_scheduler_get_processor();
|
||||
printf("On cpu %d\n", cpu);
|
||||
rtems_test_assert(cpu == i);
|
||||
printf( "On cpu %d\n", cpu );
|
||||
rtems_test_assert( cpu == i );
|
||||
}
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -98,7 +97,7 @@ static void Init(rtems_task_argument arg)
|
||||
test();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -108,11 +107,11 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS NUM_CPUS
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
|
||||
#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 8
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 8
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
@@ -44,135 +44,136 @@ const char rtems_test_name[] = "SMPSCHEDAFFINITY 4";
|
||||
#define TASK_COUNT 2
|
||||
|
||||
struct task_data_t {
|
||||
rtems_id id;
|
||||
int expected_cpu;
|
||||
bool ran;
|
||||
int actual_cpu;
|
||||
rtems_id id;
|
||||
int expected_cpu;
|
||||
bool ran;
|
||||
int actual_cpu;
|
||||
};
|
||||
|
||||
struct task_data_t task_data = {
|
||||
0x0, 2, false, 0xff
|
||||
};
|
||||
struct task_data_t task_data = { 0x0, 2, false, 0xff };
|
||||
|
||||
rtems_id task_sem;
|
||||
rtems_id task_sem;
|
||||
|
||||
static void task(rtems_task_argument arg);
|
||||
static void task( rtems_task_argument arg );
|
||||
|
||||
static void test_delay(rtems_interval ticks)
|
||||
{
|
||||
static void test_delay( rtems_interval ticks )
|
||||
{
|
||||
rtems_interval start, stop;
|
||||
start = rtems_clock_get_ticks_since_boot();
|
||||
do {
|
||||
stop = rtems_clock_get_ticks_since_boot();
|
||||
} while ( (stop - start) < ticks );
|
||||
} while ( ( stop - start ) < ticks );
|
||||
}
|
||||
|
||||
/*
|
||||
* Task that continually sets the cpu and
|
||||
* run indicators without blocking.
|
||||
*/
|
||||
static void task(rtems_task_argument arg)
|
||||
static void task( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
rtems_status_code sc;
|
||||
rtems_status_code sc;
|
||||
|
||||
while (true) {
|
||||
sc = rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0);
|
||||
if (sc == RTEMS_SUCCESSFUL) {
|
||||
while ( true ) {
|
||||
sc = rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 );
|
||||
if ( sc == RTEMS_SUCCESSFUL ) {
|
||||
task_data.ran = true;
|
||||
task_data.actual_cpu = rtems_scheduler_get_processor();
|
||||
rtems_semaphore_release(task_sem);
|
||||
rtems_semaphore_release( task_sem );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
uint32_t cpu_count;
|
||||
uint32_t cpu;
|
||||
uint32_t i;
|
||||
cpu_set_t cpuset;
|
||||
rtems_status_code sc;
|
||||
uint32_t cpu_count;
|
||||
uint32_t cpu;
|
||||
uint32_t i;
|
||||
cpu_set_t cpuset;
|
||||
|
||||
/* Get the number of processors that we are using. */
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
if (cpu_count < 2) {
|
||||
printf("Error: Test requires at least 2 cpus\n");
|
||||
if ( cpu_count < 2 ) {
|
||||
printf( "Error: Test requires at least 2 cpus\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Create Semaphore\n");
|
||||
sc = rtems_semaphore_create(
|
||||
rtems_build_name('S', 'E', 'M', '0'),
|
||||
1, /* initial count = 1 */
|
||||
RTEMS_BINARY_SEMAPHORE |
|
||||
RTEMS_PRIORITY |
|
||||
RTEMS_PRIORITY_CEILING,
|
||||
printf( "Create Semaphore\n" );
|
||||
sc = rtems_semaphore_create(
|
||||
rtems_build_name( 'S', 'E', 'M', '0' ),
|
||||
1, /* initial count = 1 */
|
||||
RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
|
||||
0,
|
||||
&task_sem
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/*
|
||||
* Create and start TA1 at a higher priority
|
||||
* than the init task.
|
||||
*/
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('T', 'A', '0', '1'),
|
||||
rtems_build_name( 'T', 'A', '0', '1' ),
|
||||
4,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_data.id
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
printf("Start TA1\n");
|
||||
printf( "Start TA1\n" );
|
||||
sc = rtems_task_start( task_data.id, task, 0 );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/*
|
||||
* Verify the Init task is running on the max core.
|
||||
*/
|
||||
printf("Verify Init task is on cpu %" PRIu32 "\n",cpu_count-1);
|
||||
*/
|
||||
printf( "Verify Init task is on cpu %" PRIu32 "\n", cpu_count - 1 );
|
||||
cpu = rtems_scheduler_get_processor();
|
||||
rtems_test_assert(cpu == (cpu_count-1));
|
||||
rtems_test_assert( cpu == ( cpu_count - 1 ) );
|
||||
|
||||
/* Walk TA1 across all of the cores */
|
||||
for(i=0; i < cpu_count; i++) {
|
||||
for ( i = 0; i < cpu_count; i++ ) {
|
||||
/* Set the Affinity to core i */
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(i, &cpuset);
|
||||
printf("Set Affinity TA1 to cpu %d\n", i);
|
||||
sc = rtems_task_set_affinity( task_data.id, sizeof(cpuset), &cpuset );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
CPU_ZERO( &cpuset );
|
||||
CPU_SET( i, &cpuset );
|
||||
printf( "Set Affinity TA1 to cpu %d\n", i );
|
||||
sc = rtems_task_set_affinity( task_data.id, sizeof( cpuset ), &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* Wait a bit to be sure it has switched cores then clear the task data */
|
||||
test_delay(50);
|
||||
while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
|
||||
test_delay( 50 );
|
||||
while (
|
||||
rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 ) != RTEMS_SUCCESSFUL
|
||||
);
|
||||
task_data.ran = false;
|
||||
task_data.expected_cpu = i;
|
||||
rtems_semaphore_release(task_sem);
|
||||
test_delay(50);
|
||||
rtems_semaphore_release( task_sem );
|
||||
test_delay( 50 );
|
||||
|
||||
/* Verify the task ran on core i */
|
||||
while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
|
||||
if (task_data.ran != true)
|
||||
printf("Error: TA01 never ran.\n");
|
||||
else
|
||||
while (
|
||||
rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 ) != RTEMS_SUCCESSFUL
|
||||
);
|
||||
if ( task_data.ran != true ) {
|
||||
printf( "Error: TA01 never ran.\n" );
|
||||
} else {
|
||||
printf(
|
||||
"TA1 expected cpu: %d actual cpu %d\n",
|
||||
"TA1 expected cpu: %d actual cpu %d\n",
|
||||
task_data.expected_cpu,
|
||||
task_data.actual_cpu
|
||||
);
|
||||
rtems_test_assert(task_data.ran == true);
|
||||
rtems_test_assert(task_data.expected_cpu == task_data.actual_cpu);
|
||||
rtems_semaphore_release(task_sem);
|
||||
}
|
||||
rtems_test_assert( task_data.ran == true );
|
||||
rtems_test_assert( task_data.expected_cpu == task_data.actual_cpu );
|
||||
rtems_semaphore_release( task_sem );
|
||||
}
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -181,7 +182,7 @@ static void Init(rtems_task_argument arg)
|
||||
test();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -193,11 +194,11 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS NUM_CPUS
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
|
||||
#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 8
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 8
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
@@ -63,89 +63,96 @@ struct task_data_t {
|
||||
int migrate_cpu;
|
||||
};
|
||||
|
||||
static struct task_data_t task_data[TASK_COUNT] = {
|
||||
{0x0, {{0xc}}, 7, false, 3, -1, 2},
|
||||
{0x0, {{0xf}}, 8, false, 2, -1, -1},
|
||||
{0x0, {{0x3}}, 5, false, 1, -1, 0},
|
||||
{0x0, {{0x9}}, 6, false, 0, -1, 3},
|
||||
{0x0, {{0x2}}, 9, false, -1, -1, 1}
|
||||
static struct task_data_t task_data[ TASK_COUNT ] = {
|
||||
{ 0x0, { { 0xc } }, 7, false, 3, -1, 2 },
|
||||
{ 0x0, { { 0xf } }, 8, false, 2, -1, -1 },
|
||||
{ 0x0, { { 0x3 } }, 5, false, 1, -1, 0 },
|
||||
{ 0x0, { { 0x9 } }, 6, false, 0, -1, 3 },
|
||||
{ 0x0, { { 0x2 } }, 9, false, -1, -1, 1 }
|
||||
};
|
||||
|
||||
rtems_id task_sem;
|
||||
rtems_id task_sem;
|
||||
|
||||
static void verify_tasks(void);
|
||||
static void verify_tasks( void );
|
||||
|
||||
/*
|
||||
* Spin loop to allow tasks to delay without yeilding the
|
||||
* processor.
|
||||
*/
|
||||
static void test_delay(rtems_interval ticks)
|
||||
static void test_delay( rtems_interval ticks )
|
||||
{
|
||||
rtems_interval start, stop;
|
||||
start = rtems_clock_get_ticks_since_boot();
|
||||
do {
|
||||
stop = rtems_clock_get_ticks_since_boot();
|
||||
} while ( (stop - start) < ticks );
|
||||
} while ( ( stop - start ) < ticks );
|
||||
}
|
||||
|
||||
static void task(rtems_task_argument arg)
|
||||
static void task( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
rtems_status_code sc;
|
||||
rtems_status_code sc;
|
||||
|
||||
while (true) {
|
||||
sc = rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0);
|
||||
if (sc == RTEMS_SUCCESSFUL) {
|
||||
task_data[arg].ran = true;
|
||||
task_data[arg].actual_cpu = rtems_scheduler_get_processor();
|
||||
rtems_semaphore_release(task_sem);
|
||||
while ( true ) {
|
||||
sc = rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 );
|
||||
if ( sc == RTEMS_SUCCESSFUL ) {
|
||||
task_data[ arg ].ran = true;
|
||||
task_data[ arg ].actual_cpu = rtems_scheduler_get_processor();
|
||||
rtems_semaphore_release( task_sem );
|
||||
}
|
||||
}
|
||||
}
|
||||
static void verify_tasks(void)
|
||||
static void verify_tasks( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("Verify Tasks Ran\n");
|
||||
printf( "Verify Tasks Ran\n" );
|
||||
|
||||
while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
|
||||
while (
|
||||
rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 ) != RTEMS_SUCCESSFUL
|
||||
);
|
||||
|
||||
/* Set Init task data */
|
||||
task_data[0].ran = true;
|
||||
task_data[0].actual_cpu = rtems_scheduler_get_processor();
|
||||
task_data[ 0 ].ran = true;
|
||||
task_data[ 0 ].actual_cpu = rtems_scheduler_get_processor();
|
||||
|
||||
/* Verify all tasks */
|
||||
for (i = 0; i < NUM_CPUS; i++) {
|
||||
if (i==0)
|
||||
printf("Init(%" PRIu32 "): ran=%d expected=%d actual=%d\n",
|
||||
task_data[i].priority,
|
||||
task_data[i].ran,
|
||||
task_data[i].expected_cpu,
|
||||
task_data[i].actual_cpu
|
||||
for ( i = 0; i < NUM_CPUS; i++ ) {
|
||||
if ( i == 0 ) {
|
||||
printf(
|
||||
"Init(%" PRIu32 "): ran=%d expected=%d actual=%d\n",
|
||||
task_data[ i ].priority,
|
||||
task_data[ i ].ran,
|
||||
task_data[ i ].expected_cpu,
|
||||
task_data[ i ].actual_cpu
|
||||
);
|
||||
else
|
||||
printf( "TA0%d(%" PRIu32 "): ran=%d expected=%d actual=%d\n",
|
||||
} else {
|
||||
printf(
|
||||
"TA0%d(%" PRIu32 "): ran=%d expected=%d actual=%d\n",
|
||||
i,
|
||||
task_data[i].priority,
|
||||
task_data[i].ran,
|
||||
task_data[i].expected_cpu,
|
||||
task_data[i].actual_cpu
|
||||
task_data[ i ].priority,
|
||||
task_data[ i ].ran,
|
||||
task_data[ i ].expected_cpu,
|
||||
task_data[ i ].actual_cpu
|
||||
);
|
||||
}
|
||||
|
||||
/* Abort test if values are not as expected */
|
||||
if ( task_data[i].expected_cpu == -1 )
|
||||
rtems_test_assert( task_data[i].ran == false );
|
||||
else {
|
||||
rtems_test_assert( task_data[i].ran == true );
|
||||
rtems_test_assert( task_data[i].expected_cpu == task_data[i].actual_cpu );
|
||||
if ( task_data[ i ].expected_cpu == -1 ) {
|
||||
rtems_test_assert( task_data[ i ].ran == false );
|
||||
} else {
|
||||
rtems_test_assert( task_data[ i ].ran == true );
|
||||
rtems_test_assert(
|
||||
task_data[ i ].expected_cpu == task_data[ i ].actual_cpu
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
rtems_semaphore_release(task_sem);
|
||||
rtems_semaphore_release( task_sem );
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
static void test( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_task_argument i;
|
||||
@@ -155,60 +162,56 @@ static void test(void)
|
||||
|
||||
/* Get the number of processors that we are using. */
|
||||
cpu_count = rtems_scheduler_get_processor_maximum();
|
||||
if (cpu_count != 4) {
|
||||
printf("Test requires a minimum of 4 cores\n");
|
||||
if ( cpu_count != 4 ) {
|
||||
printf( "Test requires a minimum of 4 cores\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
size = sizeof(cpu_set_t);
|
||||
task_data[0].id = rtems_task_self();
|
||||
printf("Create Semaphore\n");
|
||||
size = sizeof( cpu_set_t );
|
||||
task_data[ 0 ].id = rtems_task_self();
|
||||
printf( "Create Semaphore\n" );
|
||||
|
||||
sc = rtems_semaphore_create(
|
||||
rtems_build_name('S', 'E', 'M', '0'),
|
||||
1, /* initial count = 1 */
|
||||
RTEMS_BINARY_SEMAPHORE |
|
||||
RTEMS_PRIORITY |
|
||||
RTEMS_PRIORITY_CEILING,
|
||||
rtems_build_name( 'S', 'E', 'M', '0' ),
|
||||
1, /* initial count = 1 */
|
||||
RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
|
||||
0,
|
||||
&task_sem
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
/* Create and start tasks on each cpu with the appropriate affinity. */
|
||||
for (i = 1; i < TASK_COUNT; i++) {
|
||||
for ( i = 1; i < TASK_COUNT; i++ ) {
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name( 'T', 'A', '0', '0' + i ),
|
||||
task_data[ i ].priority,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_data[ i ].id
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('T', 'A', '0', '0'+i),
|
||||
task_data[ i ].priority,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&task_data[ i ].id
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_set_affinity(
|
||||
task_data[ i ].id,
|
||||
size,
|
||||
&task_data[ i ].cpuset
|
||||
);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_set_affinity(
|
||||
task_data[ i ].id,
|
||||
size,
|
||||
&task_data[i].cpuset
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
printf(
|
||||
"Start TA%" PRIdrtems_task_argument " at priority %"
|
||||
PRIu32 " on cpu %d\n",
|
||||
i,
|
||||
task_data[i].priority,
|
||||
task_data[i].expected_cpu
|
||||
);
|
||||
sc = rtems_task_start( task_data[ i ].id, task, i );
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
printf(
|
||||
"Start TA%" PRIdrtems_task_argument " at priority %" PRIu32
|
||||
" on cpu %d\n",
|
||||
i,
|
||||
task_data[ i ].priority,
|
||||
task_data[ i ].expected_cpu
|
||||
);
|
||||
sc = rtems_task_start( task_data[ i ].id, task, i );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
/* spin for 100 ticks */
|
||||
test_delay(100);
|
||||
test_delay( 100 );
|
||||
|
||||
verify_tasks();
|
||||
|
||||
@@ -217,27 +220,29 @@ static void test(void)
|
||||
printf(
|
||||
"Set TA%" PRIdrtems_task_argument " priority %" PRIu32 "\n",
|
||||
i,
|
||||
task_data[i].priority
|
||||
task_data[ i ].priority
|
||||
);
|
||||
sc = rtems_task_set_priority(
|
||||
task_data[ i ].id,
|
||||
task_data[ i ].priority,
|
||||
&priority
|
||||
);
|
||||
test_delay(25);
|
||||
test_delay( 25 );
|
||||
|
||||
while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
|
||||
for (i = 0; i < TASK_COUNT; i++) {
|
||||
while (
|
||||
rtems_semaphore_obtain( task_sem, RTEMS_NO_WAIT, 0 ) != RTEMS_SUCCESSFUL
|
||||
);
|
||||
for ( i = 0; i < TASK_COUNT; i++ ) {
|
||||
task_data[ i ].expected_cpu = task_data[ i ].migrate_cpu;
|
||||
task_data[ i ].actual_cpu = -1;
|
||||
task_data[ i ].ran = false;
|
||||
}
|
||||
rtems_semaphore_release(task_sem);
|
||||
test_delay(25);
|
||||
rtems_semaphore_release( task_sem );
|
||||
test_delay( 25 );
|
||||
verify_tasks();
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -246,7 +251,7 @@ static void Init(rtems_task_argument arg)
|
||||
test();
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
@@ -256,13 +261,13 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS NUM_CPUS
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
|
||||
#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 7
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 7
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
@@ -37,96 +37,96 @@
|
||||
const char rtems_test_name[] = "SMPSCHEDEDF 1";
|
||||
|
||||
typedef struct {
|
||||
rtems_id task[2];
|
||||
rtems_id task[ 2 ];
|
||||
} test_context;
|
||||
|
||||
static test_context test_instance;
|
||||
|
||||
static void t(test_context *ctx, rtems_interval p, long nanoseconds)
|
||||
static void t( test_context *ctx, rtems_interval p, long nanoseconds )
|
||||
{
|
||||
(void) ctx;
|
||||
|
||||
rtems_status_code sc;
|
||||
rtems_id period;
|
||||
rtems_name name;
|
||||
rtems_id period;
|
||||
rtems_name name;
|
||||
|
||||
sc = rtems_object_get_classic_name(rtems_task_self(), &name);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_object_get_classic_name( rtems_task_self(), &name );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_rate_monotonic_create(name, &period);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_rate_monotonic_create( name, &period );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
while (true) {
|
||||
rtems_test_busy_cpu_usage(0, nanoseconds);
|
||||
while ( true ) {
|
||||
rtems_test_busy_cpu_usage( 0, nanoseconds );
|
||||
|
||||
sc = rtems_rate_monotonic_period(period, p);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_rate_monotonic_period( period, p );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
}
|
||||
}
|
||||
|
||||
static void t1(rtems_task_argument arg)
|
||||
static void t1( rtems_task_argument arg )
|
||||
{
|
||||
test_context *ctx = (test_context *) arg;
|
||||
|
||||
t(ctx, 50, 25000000);
|
||||
t( ctx, 50, 25000000 );
|
||||
}
|
||||
|
||||
static void t2(rtems_task_argument arg)
|
||||
static void t2( rtems_task_argument arg )
|
||||
{
|
||||
test_context *ctx = (test_context *) arg;
|
||||
|
||||
t(ctx, 75, 30000000);
|
||||
t( ctx, 75, 30000000 );
|
||||
}
|
||||
|
||||
static void test(test_context *ctx)
|
||||
static void test( test_context *ctx )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('T', '1', ' ', ' '),
|
||||
rtems_build_name( 'T', '1', ' ', ' ' ),
|
||||
2,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&ctx->task[0]
|
||||
&ctx->task[ 0 ]
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('T', '2', ' ', ' '),
|
||||
rtems_build_name( 'T', '2', ' ', ' ' ),
|
||||
2,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&ctx->task[1]
|
||||
&ctx->task[ 1 ]
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_wake_after(1);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_wake_after( 1 );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_start(ctx->task[0], t1, (rtems_task_argument) ctx);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_start( ctx->task[ 0 ], t1, (rtems_task_argument) ctx );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_start(ctx->task[1], t2, (rtems_task_argument) ctx);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_start( ctx->task[ 1 ], t2, (rtems_task_argument) ctx );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
rtems_cpu_usage_reset();
|
||||
|
||||
sc = rtems_task_wake_after(50 * 75);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_wake_after( 50 * 75 );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_suspend(ctx->task[0]);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_suspend( ctx->task[ 0 ] );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
sc = rtems_task_suspend(ctx->task[1]);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
sc = rtems_task_suspend( ctx->task[ 1 ] );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
rtems_cpu_usage_report_with_plugin(&rtems_test_printer);
|
||||
rtems_rate_monotonic_report_statistics_with_plugin(&rtems_test_printer);
|
||||
rtems_cpu_usage_report_with_plugin( &rtems_test_printer );
|
||||
rtems_rate_monotonic_report_statistics_with_plugin( &rtems_test_printer );
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
@@ -134,10 +134,10 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
test(ctx);
|
||||
test( ctx );
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
|
||||
@@ -145,7 +145,7 @@ static void Init(rtems_task_argument arg)
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 3
|
||||
#define CONFIGURE_MAXIMUM_TASKS 3
|
||||
#define CONFIGURE_MAXIMUM_PERIODS 2
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS 1
|
||||
@@ -154,13 +154,13 @@ static void Init(rtems_task_argument arg)
|
||||
|
||||
#include <rtems/scheduler.h>
|
||||
|
||||
RTEMS_SCHEDULER_EDF_SMP(a);
|
||||
RTEMS_SCHEDULER_EDF_SMP( a );
|
||||
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_EDF_SMP(a, rtems_build_name('E', 'D', 'F', ' '))
|
||||
RTEMS_SCHEDULER_TABLE_EDF_SMP( a, rtems_build_name( 'E', 'D', 'F', ' ' ) )
|
||||
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY)
|
||||
RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY )
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user