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 #include <tmacros.h>
0034 #include "test_support.h"
0035
0036 const char rtems_test_name[] = "SMP 7";
0037
0038 volatile bool TaskRan = false;
0039 volatile bool TSRFired = false;
0040 rtems_id Semaphore;
0041
0042 rtems_task Init(
0043 rtems_task_argument argument
0044 );
0045
0046 rtems_task Test_task(
0047 rtems_task_argument argument
0048 );
0049
0050 static void success(void)
0051 {
0052 TEST_END( );
0053 rtems_test_exit( 0 );
0054 }
0055
0056 rtems_task Test_task(
0057 rtems_task_argument argument
0058 )
0059 {
0060 uint32_t cpu_num;
0061 rtems_status_code sc;
0062 char name[5];
0063 char *p;
0064
0065
0066 p = rtems_object_get_name( RTEMS_SELF, 5, name );
0067 rtems_test_assert( p != NULL );
0068
0069
0070 cpu_num = rtems_scheduler_get_processor();
0071
0072
0073 locked_printf(" CPU %" PRIu32 " runnng Task %s and blocking\n", cpu_num, name);
0074
0075 sc = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
0076 directive_failed( sc,"obtain in test task");
0077
0078 if ( !TSRFired )
0079 locked_printf( "*** ERROR TSR DID NOT FIRE BUT TEST TASK AWAKE***" );
0080
0081
0082 locked_printf(
0083 " CPU %" PRIu32 " running Task %s after semaphore release\n",
0084 cpu_num,
0085 name
0086 );
0087
0088 TaskRan = true;
0089
0090 rtems_task_exit();
0091 }
0092
0093
0094 static rtems_timer_service_routine TimerMethod(
0095 rtems_id timer,
0096 void *arg
0097 )
0098 {
0099
0100
0101
0102 TSRFired = true;
0103
0104 rtems_semaphore_release( Semaphore );
0105 }
0106
0107 rtems_task Init(
0108 rtems_task_argument argument
0109 )
0110 {
0111 int cpu_num;
0112 rtems_id id;
0113 rtems_status_code status;
0114 rtems_interval per_second;
0115 rtems_interval then;
0116 rtems_id Timer;
0117
0118 locked_print_initialize();
0119 TEST_BEGIN();
0120
0121 if ( rtems_scheduler_get_processor_maximum() == 1 ) {
0122 success();
0123 }
0124
0125
0126 status = rtems_semaphore_create(
0127 rtems_build_name ('S', 'E', 'M', '1'),
0128 1,
0129 RTEMS_LOCAL |
0130 RTEMS_SIMPLE_BINARY_SEMAPHORE |
0131 RTEMS_PRIORITY,
0132 1,
0133 &Semaphore
0134 );
0135 directive_failed( status, "rtems_semaphore_create" );
0136
0137
0138 status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0);
0139 directive_failed( status,"rtems_semaphore_obtain of SEM1\n");
0140
0141
0142 status = rtems_task_create(
0143 rtems_build_name( 'T', 'A', '1', ' ' ),
0144 1,
0145 RTEMS_MINIMUM_STACK_SIZE,
0146 RTEMS_DEFAULT_MODES,
0147 RTEMS_DEFAULT_ATTRIBUTES,
0148 &id
0149 );
0150 directive_failed( status, "task create" );
0151
0152 cpu_num = rtems_scheduler_get_processor();
0153 locked_printf(" CPU %d start task TA1\n", cpu_num );
0154 status = rtems_task_start( id, Test_task, 1 );
0155 directive_failed( status, "task start" );
0156
0157
0158 locked_printf(" CPU %d create and start timer\n", cpu_num );
0159 status = rtems_timer_create( rtems_build_name( 'T', 'M', 'R', '1' ), &Timer);
0160 directive_failed( status, "rtems_timer_create" );
0161
0162 per_second = rtems_clock_get_ticks_per_second();
0163 status = rtems_timer_fire_after( Timer, 2 * per_second, TimerMethod, NULL );
0164 directive_failed( status, "rtems_timer_fire_after");
0165
0166
0167
0168
0169
0170
0171 then = rtems_clock_get_ticks_since_boot() + 4 * per_second;
0172 while (1) {
0173 if ( rtems_clock_get_ticks_since_boot() > then )
0174 break;
0175 if ( TSRFired && TaskRan )
0176 break;
0177 };
0178
0179
0180 if ( !TSRFired )
0181 locked_printf( "*** ERROR TSR DID NOT FIRE ***" );
0182
0183 if ( !TaskRan ) {
0184 locked_printf( "*** ERROR TASK DID NOT RUN ***" );
0185 rtems_test_exit(0);
0186 }
0187
0188
0189 success();
0190 }
0191
0192
0193
0194 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0195 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0196
0197 #define CONFIGURE_MAXIMUM_PROCESSORS 2
0198 #define CONFIGURE_MAXIMUM_TIMERS 1
0199
0200 #define CONFIGURE_MAXIMUM_TASKS 2
0201 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0202
0203 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0204 #define CONFIGURE_MAXIMUM_SEMAPHORES 2
0205
0206 #define CONFIGURE_INIT
0207
0208 #include <rtems/confdefs.h>
0209