File indexing completed on 2025-05-11 08:24:35
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
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 #ifdef HAVE_CONFIG_H
0048 #include "config.h"
0049 #endif
0050
0051 #define CONFIGURE_INIT
0052 #include "system.h"
0053
0054 rtems_task Init(
0055 rtems_task_argument argument
0056 )
0057 {
0058 rtems_status_code status;
0059
0060 printf(
0061 "\n\n*** TEST 10 -- NODE %" PRIu32 " ***\n",
0062 rtems_object_get_local_node()
0063 );
0064
0065 Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
0066 Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
0067 Task_name[ 3 ] = rtems_build_name( 'S', 'A', '3', ' ' );
0068
0069 Queue_name[ 1 ] = rtems_build_name( 'M', 'S', 'G', ' ' );
0070
0071 Semaphore_name[ 1 ] = rtems_build_name( 'S', 'E', 'M', ' ' );
0072
0073 if ( rtems_object_get_local_node() == 1 ) {
0074 puts( "Creating Message Queue (Global)" );
0075 status = rtems_message_queue_create(
0076 Queue_name[ 1 ],
0077 3,
0078 16,
0079 RTEMS_GLOBAL,
0080 &Queue_id[ 1 ]
0081 );
0082 directive_failed( status, "rtems_message_queue_create" );
0083
0084 puts( "Creating Semaphore (Global)" );
0085 status = rtems_semaphore_create(
0086 Semaphore_name[ 1 ],
0087 0,
0088 RTEMS_GLOBAL | RTEMS_PRIORITY,
0089 RTEMS_NO_PRIORITY,
0090 &Semaphore_id[ 1 ]
0091 );
0092 directive_failed( status, "rtems_semaphore_create" );
0093
0094 status = rtems_task_wake_after( 10 * rtems_clock_get_ticks_per_second() );
0095 directive_failed( status, "rtems_task_wake_after" );
0096
0097 } else {
0098
0099 puts( "Creating Test_task 1 (local)" );
0100 status = rtems_task_create(
0101 Task_name[ 1 ],
0102 1,
0103 RTEMS_MINIMUM_STACK_SIZE,
0104 RTEMS_TIMESLICE,
0105 RTEMS_DEFAULT_ATTRIBUTES,
0106 &Task_id[ 1 ]
0107 );
0108 directive_failed( status, "rtems_task_create" );
0109
0110 puts( "Starting Test_task 1 (local)" );
0111 status = rtems_task_start( Task_id[ 1 ], Test_task1, 0 );
0112 directive_failed( status, "rtems_task_start" );
0113
0114 puts( "Creating Test_task 2 (local)" );
0115 status = rtems_task_create(
0116 Task_name[ 2 ],
0117 1,
0118 RTEMS_MINIMUM_STACK_SIZE,
0119 RTEMS_TIMESLICE,
0120 RTEMS_DEFAULT_ATTRIBUTES,
0121 &Task_id[ 2 ]
0122 );
0123 directive_failed( status, "rtems_task_create" );
0124
0125 puts( "Starting Test_task 2 (local)" );
0126 status = rtems_task_start( Task_id[ 2 ], Test_task2, 0 );
0127 directive_failed( status, "rtems_task_start" );
0128
0129 puts( "Creating Test_task 3 (local)" );
0130 status = rtems_task_create(
0131 Task_name[ 3 ],
0132 1,
0133 RTEMS_MINIMUM_STACK_SIZE,
0134 RTEMS_TIMESLICE,
0135 RTEMS_DEFAULT_ATTRIBUTES,
0136 &Task_id[ 3 ]
0137 );
0138 directive_failed( status, "rtems_task_create" );
0139
0140 puts( "Starting Test_task 3 (local)" );
0141 status = rtems_task_start( Task_id[ 3 ], Test_task2, 0 );
0142 directive_failed( status, "rtems_task_start" );
0143
0144 puts( "Sleeping for 1 seconds ..." );
0145 status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0146 directive_failed( status, "rtems_task_wake_after" );
0147
0148 puts( "Deleting Test_task2" );
0149 status = rtems_task_delete( Task_id[ 2 ] );
0150 directive_failed( status, "rtems_task_delete of Task 2" );
0151
0152 puts( "Deleting Test_task1" );
0153 status = rtems_task_delete( Task_id[ 1 ] );
0154 directive_failed( status, "rtems_task_delete of Task 1" );
0155
0156 puts( "Restarting Test_task3" );
0157 status = rtems_task_restart( Task_id[ 3 ], 1 );
0158 directive_failed( status, "rtems_task_restart of Task 3" );
0159
0160 }
0161 puts( "*** END OF TEST 10 ***" );
0162 rtems_test_exit( 0 );
0163 }