File indexing completed on 2025-05-11 08:24:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #define CONFIGURE_INIT
0034 #include "system.h"
0035
0036 #include <stdio.h>
0037 #include <inttypes.h>
0038
0039 const char rtems_test_name[] = "SMP 3";
0040
0041 static void success(void)
0042 {
0043 TEST_END();
0044 rtems_test_exit( 0 );
0045 }
0046
0047 void Loop() {
0048 volatile int i;
0049
0050 for (i=0; i<300000; i++);
0051 }
0052
0053 void PrintTaskInfo(
0054 const char *task_name
0055 )
0056 {
0057 uint32_t cpu_num;
0058
0059 cpu_num = rtems_scheduler_get_processor();
0060
0061 locked_printf(" CPU %" PRIu32 " running task %s\n", cpu_num, task_name );
0062 }
0063
0064 rtems_task Init(
0065 rtems_task_argument argument
0066 )
0067 {
0068 uint32_t i;
0069 char ch = '0';
0070 rtems_id id;
0071 rtems_status_code status;
0072 uint32_t cpu_max;
0073
0074 Loop();
0075
0076 TEST_BEGIN();
0077
0078 locked_print_initialize();
0079 cpu_max = rtems_scheduler_get_processor_maximum();
0080
0081 if ( cpu_max == 1 ) {
0082 success();
0083 }
0084
0085
0086 TaskRan[0] = true;
0087 for ( i=1; i<cpu_max ; i++ ) {
0088 TaskRan[i] = false;
0089 }
0090
0091
0092 PrintTaskInfo( "Init" );
0093
0094
0095 for ( i=1; i < cpu_max; i++ ){
0096
0097 ch = '0' + i;
0098
0099 status = rtems_task_create(
0100 rtems_build_name( 'T', 'A', ch, ' ' ),
0101 CONFIGURE_INIT_TASK_PRIORITY + (2*i),
0102 RTEMS_MINIMUM_STACK_SIZE,
0103 RTEMS_PREEMPT,
0104 RTEMS_FLOATING_POINT,
0105 &id
0106 );
0107 directive_failed( status, "rtems_task_create" );
0108 status = rtems_task_start( id, Test_task, i );
0109 directive_failed( status, "rtems_task_start" );
0110
0111
0112
0113
0114 while (TaskRan[i] == false)
0115 ;
0116 }
0117
0118
0119 status = rtems_task_create(
0120 rtems_build_name( 'T', 'A', ch + 1, ' ' ),
0121 3,
0122 RTEMS_MINIMUM_STACK_SIZE,
0123 RTEMS_PREEMPT,
0124 RTEMS_FLOATING_POINT,
0125 &id
0126 );
0127 directive_failed( status, "rtems_task_create" );
0128 status = rtems_task_start(id,Test_task,cpu_max);
0129 directive_failed( status, "rtems_task_start" );
0130
0131
0132 while (1) {
0133 TestFinished = true;
0134 for ( i=1; i < (cpu_max+1) ; i++ ) {
0135 if (TaskRan[i] == false)
0136 TestFinished = false;
0137 }
0138 if (TestFinished) {
0139 success();
0140 }
0141 }
0142
0143 rtems_test_exit( 0 );
0144 }