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 2";
0040
0041 static void success(void)
0042 {
0043 TEST_END();
0044 rtems_test_exit( 0 );
0045 }
0046
0047 rtems_task Init(
0048 rtems_task_argument argument
0049 )
0050 {
0051 int i;
0052 char ch;
0053 uint32_t cpu_num;
0054 rtems_id id;
0055 rtems_status_code status;
0056 char str[80];
0057
0058 TEST_BEGIN();
0059
0060 locked_print_initialize();
0061
0062 if ( rtems_scheduler_get_processor_maximum() == 1 ) {
0063 success();
0064 }
0065
0066
0067 status = rtems_semaphore_create(
0068 rtems_build_name ('S', 'E', 'M', '1'),
0069 1,
0070 RTEMS_LOCAL |
0071 RTEMS_SIMPLE_BINARY_SEMAPHORE |
0072 RTEMS_PRIORITY,
0073 1,
0074 &Semaphore);
0075 directive_failed( status, "rtems_semaphore_create" );
0076
0077
0078 status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0);
0079 directive_failed( status,"rtems_semaphore_obtain of SEM1\n");
0080
0081 for ( i=1; i < rtems_scheduler_get_processor_maximum(); i++ ){
0082
0083
0084 ch = '0' + i;
0085
0086 status = rtems_task_create(
0087 rtems_build_name( 'T', 'A', ch, ' ' ),
0088 1,
0089 RTEMS_MINIMUM_STACK_SIZE,
0090 RTEMS_DEFAULT_MODES,
0091 RTEMS_DEFAULT_ATTRIBUTES,
0092 &id
0093 );
0094
0095 cpu_num = rtems_scheduler_get_processor();
0096 locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);
0097 status = rtems_task_start( id, Test_task, i+1 );
0098 directive_failed( status, str );
0099 }
0100
0101
0102
0103
0104 status = rtems_semaphore_release( Semaphore );
0105 directive_failed( status,"rtems_semaphore_release of SEM1\n");
0106
0107
0108
0109
0110
0111 while (Log_index < LOG_SIZE)
0112 ;
0113
0114 for (i=0; i< LOG_SIZE; i++) {
0115 if ( Log[i].IsLocked ) {
0116 locked_printf(
0117 " CPU %d Task TA%" PRIu32 " Obtain\n",
0118 Log[i].cpu_num,
0119 Log[i].task_index
0120 );
0121 } else {
0122 locked_printf(
0123 " CPU %d Task TA%" PRIu32 " Release\n",
0124 Log[i].cpu_num,
0125 Log[i].task_index
0126 );
0127 }
0128 }
0129
0130 success();
0131 }