[ac7d5ef0] | 1 | /* |
---|
[1055ce20] | 2 | * COPYRIGHT (c) 1989-2009. |
---|
[ac7d5ef0] | 3 | * On-Line Applications Research Corporation (OAR). |
---|
| 4 | * |
---|
[98e4ebf5] | 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
[95a81ab] | 7 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 8 | */ |
---|
| 9 | |
---|
[a4bc4d6e] | 10 | #ifdef HAVE_CONFIG_H |
---|
| 11 | #include "config.h" |
---|
| 12 | #endif |
---|
| 13 | |
---|
[d1128e2] | 14 | #define CONFIGURE_INIT |
---|
[ac7d5ef0] | 15 | #include "system.h" |
---|
| 16 | |
---|
| 17 | rtems_id Timer_id[ OPERATION_COUNT+1 ]; |
---|
| 18 | |
---|
| 19 | rtems_time_of_day time_of_day; |
---|
| 20 | |
---|
| 21 | void null_delay( |
---|
| 22 | rtems_id ignored_id, |
---|
| 23 | void *ignored_address |
---|
| 24 | ); |
---|
| 25 | |
---|
| 26 | rtems_task Low_task( |
---|
| 27 | rtems_task_argument argument |
---|
| 28 | ); |
---|
| 29 | |
---|
| 30 | rtems_task Middle_tasks( |
---|
| 31 | rtems_task_argument argument |
---|
| 32 | ); |
---|
| 33 | |
---|
| 34 | rtems_task High_task( |
---|
| 35 | rtems_task_argument argument |
---|
| 36 | ); |
---|
| 37 | |
---|
[4389287a] | 38 | int operation_count = OPERATION_COUNT; |
---|
[ac7d5ef0] | 39 | |
---|
| 40 | rtems_task Init( |
---|
| 41 | rtems_task_argument argument |
---|
| 42 | ) |
---|
| 43 | { |
---|
| 44 | |
---|
| 45 | rtems_task_priority priority; |
---|
[1055ce20] | 46 | int index; |
---|
[ac7d5ef0] | 47 | rtems_id id; |
---|
| 48 | rtems_task_entry task_entry; |
---|
| 49 | rtems_status_code status; |
---|
| 50 | |
---|
[3a4ae6c] | 51 | Print_Warning(); |
---|
| 52 | |
---|
[ac7d5ef0] | 53 | puts( "\n\n*** TIME TEST 23 ***" ); |
---|
| 54 | |
---|
[dbf4f17] | 55 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 56 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[dbf4f17] | 57 | (void) benchmark_timer_empty_function(); |
---|
| 58 | overhead = benchmark_timer_read(); |
---|
[ac7d5ef0] | 59 | |
---|
[4389287a] | 60 | priority = 2; |
---|
| 61 | if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 ) |
---|
| 62 | operation_count = RTEMS_MAXIMUM_PRIORITY - 2; |
---|
[ac7d5ef0] | 63 | |
---|
[4389287a] | 64 | for( index=1 ; index <= operation_count ; index++ ) { |
---|
[ac7d5ef0] | 65 | status = rtems_task_create( |
---|
| 66 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
| 67 | priority, |
---|
[3652ad35] | 68 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 69 | RTEMS_DEFAULT_MODES, |
---|
| 70 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 71 | &id |
---|
| 72 | ); |
---|
| 73 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
| 74 | |
---|
| 75 | if ( index == 1 ) task_entry = High_task; |
---|
[4389287a] | 76 | else if ( index == operation_count ) task_entry = Low_task; |
---|
[ac7d5ef0] | 77 | else task_entry = Middle_tasks; |
---|
| 78 | |
---|
| 79 | status = rtems_task_start( id, task_entry, 0 ); |
---|
| 80 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
| 81 | |
---|
| 82 | priority++; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 86 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | void null_delay( |
---|
| 90 | rtems_id ignored_id, |
---|
| 91 | void *ignored_address |
---|
| 92 | ) |
---|
| 93 | { |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | rtems_task High_task( |
---|
| 97 | rtems_task_argument argument |
---|
| 98 | ) |
---|
| 99 | { |
---|
[0720ff4] | 100 | uint32_t index; |
---|
[ac7d5ef0] | 101 | rtems_status_code status; |
---|
| 102 | int i; |
---|
| 103 | |
---|
[dbf4f17] | 104 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 105 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[dbf4f17] | 106 | (void) benchmark_timer_empty_function(); |
---|
| 107 | overhead = benchmark_timer_read(); |
---|
[ac7d5ef0] | 108 | |
---|
[dbf4f17] | 109 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 110 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 111 | (void) rtems_timer_create( index, &Timer_id[ index ] ); |
---|
[dbf4f17] | 112 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 113 | |
---|
| 114 | put_time( |
---|
| 115 | "rtems_timer_create", |
---|
| 116 | end_time, |
---|
| 117 | OPERATION_COUNT, |
---|
| 118 | overhead, |
---|
| 119 | CALLING_OVERHEAD_TIMER_CREATE |
---|
| 120 | ); |
---|
| 121 | |
---|
[dbf4f17] | 122 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 123 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 124 | (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); |
---|
[dbf4f17] | 125 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 126 | |
---|
| 127 | put_time( |
---|
[5c491aef] | 128 | "rtems_timer_fire_after: inactive", |
---|
[ac7d5ef0] | 129 | end_time, |
---|
| 130 | OPERATION_COUNT, |
---|
| 131 | overhead, |
---|
| 132 | CALLING_OVERHEAD_TIMER_FIRE_AFTER |
---|
| 133 | ); |
---|
| 134 | |
---|
[dbf4f17] | 135 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 136 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 137 | (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); |
---|
[dbf4f17] | 138 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 139 | |
---|
| 140 | put_time( |
---|
[5c491aef] | 141 | "rtems_timer_fire_after: active", |
---|
[ac7d5ef0] | 142 | end_time, |
---|
| 143 | OPERATION_COUNT, |
---|
| 144 | overhead, |
---|
| 145 | CALLING_OVERHEAD_TIMER_FIRE_AFTER |
---|
| 146 | ); |
---|
| 147 | |
---|
[dbf4f17] | 148 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 149 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 150 | (void) rtems_timer_cancel( Timer_id[ index ] ); |
---|
[dbf4f17] | 151 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 152 | |
---|
| 153 | put_time( |
---|
[5c491aef] | 154 | "rtems_timer_cancel: active", |
---|
[ac7d5ef0] | 155 | end_time, |
---|
| 156 | OPERATION_COUNT, |
---|
| 157 | overhead, |
---|
| 158 | CALLING_OVERHEAD_TIMER_CANCEL |
---|
| 159 | ); |
---|
| 160 | |
---|
[dbf4f17] | 161 | for ( benchmark_timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ ) |
---|
| 162 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 163 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 164 | (void) rtems_timer_cancel( Timer_id[ index ] ); |
---|
[dbf4f17] | 165 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 166 | |
---|
| 167 | put_time( |
---|
[5c491aef] | 168 | "rtems_timer_cancel: inactive", |
---|
[ac7d5ef0] | 169 | end_time, |
---|
| 170 | OPERATION_COUNT, |
---|
| 171 | overhead, |
---|
| 172 | CALLING_OVERHEAD_TIMER_CANCEL |
---|
| 173 | ); |
---|
| 174 | |
---|
[dbf4f17] | 175 | for ( benchmark_timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ ) |
---|
| 176 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 177 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 178 | (void) rtems_timer_reset( Timer_id[ index ] ); |
---|
[dbf4f17] | 179 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 180 | |
---|
| 181 | put_time( |
---|
[5c491aef] | 182 | "rtems_timer_reset: inactive", |
---|
[ac7d5ef0] | 183 | end_time, |
---|
| 184 | OPERATION_COUNT, |
---|
| 185 | overhead, |
---|
| 186 | CALLING_OVERHEAD_TIMER_RESET |
---|
| 187 | ); |
---|
| 188 | |
---|
[dbf4f17] | 189 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 190 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 191 | (void) rtems_timer_reset( Timer_id[ index ] ); |
---|
[dbf4f17] | 192 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 193 | |
---|
| 194 | put_time( |
---|
[5c491aef] | 195 | "rtems_timer_reset: active", |
---|
[ac7d5ef0] | 196 | end_time, |
---|
| 197 | OPERATION_COUNT, |
---|
| 198 | overhead, |
---|
| 199 | CALLING_OVERHEAD_TIMER_RESET |
---|
| 200 | ); |
---|
| 201 | |
---|
| 202 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 203 | (void) rtems_timer_reset( Timer_id[ index ] ); |
---|
| 204 | |
---|
| 205 | build_time( &time_of_day, 12, 31, 1988, 9, 0, 0, 0 ); |
---|
| 206 | |
---|
| 207 | status = rtems_clock_set( &time_of_day ); |
---|
| 208 | directive_failed( status, "rtems_clock_set" ); |
---|
| 209 | |
---|
| 210 | time_of_day.year = 1989; |
---|
| 211 | |
---|
[dbf4f17] | 212 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 213 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 214 | (void) rtems_timer_fire_when( |
---|
| 215 | Timer_id[ index ], &time_of_day, null_delay, NULL ); |
---|
[dbf4f17] | 216 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 217 | |
---|
| 218 | put_time( |
---|
[5c491aef] | 219 | "rtems_timer_fire_when: inactive", |
---|
[ac7d5ef0] | 220 | end_time, |
---|
| 221 | OPERATION_COUNT, |
---|
| 222 | overhead, |
---|
| 223 | CALLING_OVERHEAD_TIMER_FIRE_WHEN |
---|
| 224 | ); |
---|
| 225 | |
---|
[dbf4f17] | 226 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 227 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 228 | (void) rtems_timer_fire_when( |
---|
| 229 | Timer_id[ index ], &time_of_day, null_delay, NULL ); |
---|
[dbf4f17] | 230 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 231 | |
---|
| 232 | put_time( |
---|
[5c491aef] | 233 | "rtems_timer_fire_when: active", |
---|
[ac7d5ef0] | 234 | end_time, |
---|
| 235 | OPERATION_COUNT, |
---|
| 236 | overhead, |
---|
| 237 | CALLING_OVERHEAD_TIMER_FIRE_WHEN |
---|
| 238 | ); |
---|
| 239 | |
---|
[dbf4f17] | 240 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 241 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 242 | (void) rtems_timer_delete( Timer_id[ index ] ); |
---|
[dbf4f17] | 243 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 244 | |
---|
| 245 | put_time( |
---|
[5c491aef] | 246 | "rtems_timer_delete: active", |
---|
[ac7d5ef0] | 247 | end_time, |
---|
| 248 | OPERATION_COUNT, |
---|
| 249 | overhead, |
---|
| 250 | CALLING_OVERHEAD_TIMER_DELETE |
---|
| 251 | ); |
---|
| 252 | |
---|
[dbf4f17] | 253 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 254 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 255 | status = rtems_timer_create( index, &Timer_id[ index ] ); |
---|
| 256 | directive_failed( status, "rtems_timer_create" ); |
---|
| 257 | |
---|
| 258 | status = rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL ); |
---|
| 259 | directive_failed( status, "rtems_timer_fire_after" ); |
---|
| 260 | |
---|
| 261 | status = rtems_timer_cancel( Timer_id[ index ] ); |
---|
| 262 | directive_failed( status, "rtems_timer_cancel" ); |
---|
| 263 | } |
---|
| 264 | |
---|
[dbf4f17] | 265 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 266 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 267 | (void) rtems_timer_delete( Timer_id[ index ] ); |
---|
[dbf4f17] | 268 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 269 | |
---|
| 270 | put_time( |
---|
[5c491aef] | 271 | "rtems_timer_delete: inactive", |
---|
[ac7d5ef0] | 272 | end_time, |
---|
| 273 | OPERATION_COUNT, |
---|
| 274 | overhead, |
---|
| 275 | CALLING_OVERHEAD_TIMER_DELETE |
---|
| 276 | ); |
---|
| 277 | |
---|
[dbf4f17] | 278 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 279 | (void) rtems_task_wake_when( &time_of_day ); |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | rtems_task Middle_tasks( |
---|
| 283 | rtems_task_argument argument |
---|
| 284 | ) |
---|
| 285 | { |
---|
| 286 | (void) rtems_task_wake_when( &time_of_day ); |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | rtems_task Low_task( |
---|
| 290 | rtems_task_argument argument |
---|
| 291 | ) |
---|
| 292 | { |
---|
[dbf4f17] | 293 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 294 | |
---|
| 295 | put_time( |
---|
| 296 | "rtems_task_wake_when", |
---|
| 297 | end_time, |
---|
[4389287a] | 298 | operation_count, |
---|
[1055ce20] | 299 | 0, |
---|
[ac7d5ef0] | 300 | CALLING_OVERHEAD_TASK_WAKE_WHEN |
---|
| 301 | ); |
---|
| 302 | |
---|
[3a4ae6c] | 303 | puts( "*** END OF TEST 23 ***" ); |
---|
[b454bc9] | 304 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 305 | } |
---|