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 23";
0043
0044 rtems_id Timer_id[ OPERATION_COUNT+1 ];
0045
0046 rtems_time_of_day time_of_day;
0047
0048 void null_delay(
0049 rtems_id ignored_id,
0050 void *ignored_address
0051 );
0052
0053 rtems_task Low_task(
0054 rtems_task_argument argument
0055 );
0056
0057 rtems_task Middle_tasks(
0058 rtems_task_argument argument
0059 );
0060
0061 rtems_task High_task(
0062 rtems_task_argument argument
0063 );
0064
0065 int operation_count = OPERATION_COUNT;
0066
0067 rtems_task Init(
0068 rtems_task_argument argument
0069 )
0070 {
0071
0072 rtems_task_priority priority;
0073 int index;
0074 rtems_id id;
0075 rtems_task_entry task_entry;
0076 rtems_status_code status;
0077
0078 Print_Warning();
0079
0080 TEST_BEGIN();
0081
0082 benchmark_timer_initialize();
0083 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0084 (void) benchmark_timer_empty_function();
0085 overhead = benchmark_timer_read();
0086
0087 priority = 2;
0088 if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
0089 operation_count = RTEMS_MAXIMUM_PRIORITY - 2;
0090
0091 for( index=1 ; index <= operation_count ; index++ ) {
0092 status = rtems_task_create(
0093 rtems_build_name( 'T', 'I', 'M', 'E' ),
0094 priority,
0095 RTEMS_MINIMUM_STACK_SIZE,
0096 RTEMS_DEFAULT_MODES,
0097 RTEMS_DEFAULT_ATTRIBUTES,
0098 &id
0099 );
0100 directive_failed( status, "rtems_task_create LOOP" );
0101
0102 if ( index == 1 ) task_entry = High_task;
0103 else if ( index == operation_count ) task_entry = Low_task;
0104 else task_entry = Middle_tasks;
0105
0106 status = rtems_task_start( id, task_entry, 0 );
0107 directive_failed( status, "rtems_task_start LOOP" );
0108
0109 priority++;
0110 }
0111
0112 rtems_task_exit();
0113 }
0114
0115 void null_delay(
0116 rtems_id ignored_id,
0117 void *ignored_address
0118 )
0119 {
0120 }
0121
0122 rtems_task High_task(
0123 rtems_task_argument argument
0124 )
0125 {
0126 uint32_t index;
0127 rtems_status_code status;
0128 int i;
0129
0130 benchmark_timer_initialize();
0131 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0132 (void) benchmark_timer_empty_function();
0133 overhead = benchmark_timer_read();
0134
0135 benchmark_timer_initialize();
0136 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0137 (void) rtems_timer_create( index, &Timer_id[ index ] );
0138 end_time = benchmark_timer_read();
0139
0140 put_time(
0141 "rtems_timer_create: only case",
0142 end_time,
0143 OPERATION_COUNT,
0144 overhead,
0145 0
0146 );
0147
0148 benchmark_timer_initialize();
0149 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0150 (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
0151 end_time = benchmark_timer_read();
0152
0153 put_time(
0154 "rtems_timer_fire_after: inactive",
0155 end_time,
0156 OPERATION_COUNT,
0157 overhead,
0158 0
0159 );
0160
0161 benchmark_timer_initialize();
0162 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0163 (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
0164 end_time = benchmark_timer_read();
0165
0166 put_time(
0167 "rtems_timer_fire_after: active",
0168 end_time,
0169 OPERATION_COUNT,
0170 overhead,
0171 0
0172 );
0173
0174 benchmark_timer_initialize();
0175 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0176 (void) rtems_timer_cancel( Timer_id[ index ] );
0177 end_time = benchmark_timer_read();
0178
0179 put_time(
0180 "rtems_timer_cancel: active",
0181 end_time,
0182 OPERATION_COUNT,
0183 overhead,
0184 0
0185 );
0186
0187 for ( benchmark_timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ )
0188 benchmark_timer_initialize();
0189 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0190 (void) rtems_timer_cancel( Timer_id[ index ] );
0191 end_time = benchmark_timer_read();
0192
0193 put_time(
0194 "rtems_timer_cancel: inactive",
0195 end_time,
0196 OPERATION_COUNT,
0197 overhead,
0198 0
0199 );
0200
0201 for ( benchmark_timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ )
0202 benchmark_timer_initialize();
0203 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0204 (void) rtems_timer_reset( Timer_id[ index ] );
0205 end_time = benchmark_timer_read();
0206
0207 put_time(
0208 "rtems_timer_reset: inactive",
0209 end_time,
0210 OPERATION_COUNT,
0211 overhead,
0212 0
0213 );
0214
0215 benchmark_timer_initialize();
0216 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0217 (void) rtems_timer_reset( Timer_id[ index ] );
0218 end_time = benchmark_timer_read();
0219
0220 put_time(
0221 "rtems_timer_reset: active",
0222 end_time,
0223 OPERATION_COUNT,
0224 overhead,
0225 0
0226 );
0227
0228 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0229 (void) rtems_timer_reset( Timer_id[ index ] );
0230
0231 build_time( &time_of_day, 12, 31, 1988, 9, 0, 0, 0 );
0232
0233 status = rtems_clock_set( &time_of_day );
0234 directive_failed( status, "rtems_clock_set" );
0235
0236 time_of_day.year = 1989;
0237
0238 benchmark_timer_initialize();
0239 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0240 (void) rtems_timer_fire_when(
0241 Timer_id[ index ], &time_of_day, null_delay, NULL );
0242 end_time = benchmark_timer_read();
0243
0244 put_time(
0245 "rtems_timer_fire_when: inactive",
0246 end_time,
0247 OPERATION_COUNT,
0248 overhead,
0249 0
0250 );
0251
0252 benchmark_timer_initialize();
0253 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0254 (void) rtems_timer_fire_when(
0255 Timer_id[ index ], &time_of_day, null_delay, NULL );
0256 end_time = benchmark_timer_read();
0257
0258 put_time(
0259 "rtems_timer_fire_when: active",
0260 end_time,
0261 OPERATION_COUNT,
0262 overhead,
0263 0
0264 );
0265
0266 benchmark_timer_initialize();
0267 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0268 (void) rtems_timer_delete( Timer_id[ index ] );
0269 end_time = benchmark_timer_read();
0270
0271 put_time(
0272 "rtems_timer_delete: active",
0273 end_time,
0274 OPERATION_COUNT,
0275 overhead,
0276 0
0277 );
0278
0279 benchmark_timer_initialize();
0280 for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
0281 status = rtems_timer_create( index, &Timer_id[ index ] );
0282 directive_failed( status, "rtems_timer_create" );
0283
0284 status = rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
0285 directive_failed( status, "rtems_timer_fire_after" );
0286
0287 status = rtems_timer_cancel( Timer_id[ index ] );
0288 directive_failed( status, "rtems_timer_cancel" );
0289 }
0290
0291 benchmark_timer_initialize();
0292 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0293 (void) rtems_timer_delete( Timer_id[ index ] );
0294 end_time = benchmark_timer_read();
0295
0296 put_time(
0297 "rtems_timer_delete: inactive",
0298 end_time,
0299 OPERATION_COUNT,
0300 overhead,
0301 0
0302 );
0303
0304 benchmark_timer_initialize();
0305 (void) rtems_task_wake_when( &time_of_day );
0306 }
0307
0308 rtems_task Middle_tasks(
0309 rtems_task_argument argument
0310 )
0311 {
0312 (void) rtems_task_wake_when( &time_of_day );
0313 }
0314
0315 rtems_task Low_task(
0316 rtems_task_argument argument
0317 )
0318 {
0319 end_time = benchmark_timer_read();
0320
0321 put_time(
0322 "rtems_task_wake_when: only case",
0323 end_time,
0324 operation_count,
0325 0,
0326 0
0327 );
0328
0329 TEST_END();
0330 rtems_test_exit( 0 );
0331 }