File indexing completed on 2025-05-11 08:24:50
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 #if !defined(OPERATION_COUNT)
0030 #define OPERATION_COUNT 100
0031 #endif
0032
0033 #ifdef HAVE_CONFIG_H
0034 #include "config.h"
0035 #endif
0036
0037 #include <rtems/btimer.h>
0038
0039 #define CONFIGURE_INIT
0040 #include "system.h"
0041
0042 const char rtems_test_name[] = "TIME TEST 6";
0043
0044 rtems_id Task_id[ OPERATION_COUNT + 1 ];
0045
0046 uint32_t Task_restarted;
0047
0048 rtems_task null_task(
0049 rtems_task_argument argument
0050 );
0051
0052 rtems_task Task_1(
0053 rtems_task_argument argument
0054 );
0055
0056 void test_init( void );
0057
0058 rtems_task Init(
0059 rtems_task_argument argument
0060 )
0061 {
0062 Print_Warning();
0063
0064 TEST_BEGIN();
0065
0066 test_init();
0067
0068 rtems_task_exit();
0069 }
0070
0071 void test_init( void )
0072 {
0073 rtems_status_code status;
0074 rtems_id id;
0075
0076 Task_restarted = OPERATION_COUNT;
0077
0078 status = rtems_task_create(
0079 rtems_build_name( 'T', 'I', 'M', 'E' ),
0080 (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
0081 RTEMS_MINIMUM_STACK_SIZE,
0082 RTEMS_DEFAULT_MODES,
0083 RTEMS_DEFAULT_ATTRIBUTES,
0084 &id
0085 );
0086 directive_failed( status, "rtems_task_create" );
0087
0088 status = rtems_task_start( id, Task_1, 0 );
0089 directive_failed( status, "rtems_task_start" );
0090 }
0091
0092 rtems_task Task_1(
0093 rtems_task_argument argument
0094 )
0095 {
0096 rtems_status_code status;
0097 uint32_t index;
0098
0099 if ( Task_restarted == OPERATION_COUNT )
0100 benchmark_timer_initialize();
0101
0102 Task_restarted--;
0103
0104 if ( Task_restarted != 0 )
0105 (void) rtems_task_restart( RTEMS_SELF, 0 );
0106
0107 end_time = benchmark_timer_read();
0108
0109 benchmark_timer_initialize();
0110 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0111 (void) benchmark_timer_empty_function();
0112 overhead = benchmark_timer_read();
0113
0114 put_time(
0115 "rtems_task_restart: calling task",
0116 end_time,
0117 OPERATION_COUNT,
0118 overhead,
0119 0
0120 );
0121
0122 for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
0123 status = rtems_task_create(
0124 rtems_build_name( 'T', 'I', 'M', 'E' ),
0125 RTEMS_MAXIMUM_PRIORITY - 1u,
0126 RTEMS_MINIMUM_STACK_SIZE,
0127 RTEMS_DEFAULT_MODES,
0128 RTEMS_DEFAULT_ATTRIBUTES,
0129 &Task_id[ index ]
0130 );
0131 directive_failed( status, "rtems_task_create loop" );
0132
0133 status = rtems_task_start( Task_id[ index ], null_task, 0 );
0134 directive_failed( status, "rtems_task_start loop" );
0135 }
0136
0137 benchmark_timer_initialize();
0138 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0139 (void) rtems_task_suspend( Task_id[ index ] );
0140 end_time = benchmark_timer_read();
0141
0142 put_time(
0143 "rtems_task_suspend: returns to caller",
0144 end_time,
0145 OPERATION_COUNT,
0146 0,
0147 0
0148 );
0149
0150 benchmark_timer_initialize();
0151 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0152 (void) rtems_task_resume( Task_id[ index ] );
0153 end_time = benchmark_timer_read();
0154
0155 put_time(
0156 "rtems_task_resume: task readied returns to caller",
0157 end_time,
0158 OPERATION_COUNT,
0159 0,
0160 0
0161 );
0162
0163 benchmark_timer_initialize();
0164 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0165 (void) rtems_task_delete( Task_id[ index ] );
0166 end_time = benchmark_timer_read();
0167
0168 put_time(
0169 "rtems_task_delete: ready task",
0170 end_time,
0171 OPERATION_COUNT,
0172 0,
0173 0
0174 );
0175
0176 TEST_END();
0177 rtems_test_exit( 0 );
0178 }
0179
0180 rtems_task null_task(
0181 rtems_task_argument argument
0182 )
0183 {
0184 while ( FOREVER )
0185 ;
0186 }