[ac7d5ef0] | 1 | /* |
---|
| 2 | * |
---|
| 3 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 4 | * On-Line Applications Research Corporation (OAR). |
---|
| 5 | * All rights assigned to U.S. Government, 1994. |
---|
| 6 | * |
---|
| 7 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 8 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 9 | * notice must appear in all copies of this file and its derivatives. |
---|
| 10 | * |
---|
| 11 | * $Id$ |
---|
| 12 | */ |
---|
| 13 | |
---|
[3a4ae6c] | 14 | #define TEST_INIT |
---|
[ac7d5ef0] | 15 | #include "system.h" |
---|
| 16 | |
---|
| 17 | rtems_id Semaphore_id; |
---|
| 18 | rtems_id Task_id[OPERATION_COUNT+1]; |
---|
| 19 | rtems_unsigned32 task_count; |
---|
| 20 | rtems_id Highest_id; |
---|
| 21 | |
---|
| 22 | rtems_task Low_tasks( |
---|
| 23 | rtems_task_argument argument |
---|
| 24 | ); |
---|
| 25 | |
---|
| 26 | rtems_task High_task( |
---|
| 27 | rtems_task_argument argument |
---|
| 28 | ); |
---|
| 29 | |
---|
| 30 | rtems_task Restart_task( |
---|
| 31 | rtems_task_argument argument |
---|
| 32 | ); |
---|
| 33 | |
---|
| 34 | void test_init(); |
---|
| 35 | |
---|
| 36 | rtems_task Init( |
---|
| 37 | rtems_task_argument argument |
---|
| 38 | ) |
---|
| 39 | { |
---|
| 40 | rtems_status_code status; |
---|
| 41 | |
---|
[3a4ae6c] | 42 | Print_Warning(); |
---|
| 43 | |
---|
[ac7d5ef0] | 44 | puts( "\n\n*** TIME TEST 4 ***" ); |
---|
| 45 | |
---|
| 46 | test_init(); |
---|
| 47 | |
---|
| 48 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 49 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | void test_init() |
---|
| 53 | { |
---|
| 54 | rtems_status_code status; |
---|
| 55 | rtems_unsigned32 index; |
---|
| 56 | |
---|
| 57 | task_count = OPERATION_COUNT; |
---|
| 58 | |
---|
| 59 | for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 60 | |
---|
| 61 | status = rtems_task_create( |
---|
| 62 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
| 63 | 10, |
---|
[3652ad35] | 64 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 65 | RTEMS_NO_PREEMPT, |
---|
| 66 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 67 | &Task_id[ index ] |
---|
| 68 | ); |
---|
| 69 | directive_failed( status, "rtems_task_create loop" ); |
---|
| 70 | |
---|
| 71 | status = rtems_task_start( Task_id[ index ], Low_tasks, 0 ); |
---|
| 72 | directive_failed( status, "rtems_task_start loop" ); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | status = rtems_semaphore_create( |
---|
| 76 | rtems_build_name( 'S', 'M', '1', ' ' ), |
---|
| 77 | 0, |
---|
| 78 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
[7f6a24ab] | 79 | RTEMS_NO_PRIORITY, |
---|
[ac7d5ef0] | 80 | &Semaphore_id |
---|
| 81 | ); |
---|
| 82 | directive_failed( status, "rtems_semaphore_create of SM1" ); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | rtems_task Highest_task( |
---|
| 86 | rtems_task_argument argument |
---|
| 87 | ) |
---|
| 88 | { |
---|
| 89 | rtems_task_priority old_priority; |
---|
| 90 | rtems_status_code status; |
---|
| 91 | |
---|
| 92 | if ( argument == 1 ) { |
---|
| 93 | |
---|
| 94 | end_time = Read_timer(); |
---|
| 95 | |
---|
| 96 | put_time( |
---|
[5c491aef] | 97 | "rtems_task_restart: blocked task -- preempts caller", |
---|
[ac7d5ef0] | 98 | end_time, |
---|
| 99 | 1, |
---|
| 100 | 0, |
---|
| 101 | CALLING_OVERHEAD_TASK_RESTART |
---|
| 102 | ); |
---|
| 103 | |
---|
| 104 | status = rtems_task_set_priority( |
---|
| 105 | RTEMS_CURRENT_PRIORITY, |
---|
| 106 | 254, |
---|
| 107 | &old_priority |
---|
| 108 | ); |
---|
| 109 | directive_failed( status, "rtems_task_set_priority" ); |
---|
| 110 | |
---|
| 111 | } else if ( argument == 2 ) { |
---|
| 112 | |
---|
| 113 | end_time = Read_timer(); |
---|
| 114 | |
---|
| 115 | put_time( |
---|
[5c491aef] | 116 | "rtems_task_restart: ready task -- preempts caller", |
---|
[ac7d5ef0] | 117 | end_time, |
---|
| 118 | 1, |
---|
| 119 | 0, |
---|
| 120 | CALLING_OVERHEAD_TASK_RESTART |
---|
| 121 | ); |
---|
| 122 | |
---|
| 123 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 124 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 125 | |
---|
| 126 | } else |
---|
| 127 | (void) rtems_semaphore_obtain( |
---|
| 128 | Semaphore_id, |
---|
| 129 | RTEMS_DEFAULT_OPTIONS, |
---|
| 130 | RTEMS_NO_TIMEOUT |
---|
| 131 | ); |
---|
| 132 | |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | rtems_task High_task( |
---|
| 136 | rtems_task_argument argument |
---|
| 137 | ) |
---|
| 138 | { |
---|
| 139 | rtems_status_code status; |
---|
| 140 | rtems_unsigned32 index; |
---|
| 141 | rtems_name name; |
---|
| 142 | rtems_task_priority old_priority; |
---|
| 143 | |
---|
| 144 | Timer_initialize(); |
---|
| 145 | (void) rtems_task_restart( Highest_id, 1 ); |
---|
| 146 | /* preempted by Higher_task */ |
---|
| 147 | |
---|
| 148 | Timer_initialize(); |
---|
| 149 | (void) rtems_task_restart( Highest_id, 2 ); |
---|
| 150 | /* preempted by Higher_task */ |
---|
| 151 | |
---|
| 152 | Timer_initialize(); |
---|
| 153 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 154 | (void) Empty_function(); |
---|
| 155 | overhead = Read_timer(); |
---|
| 156 | |
---|
| 157 | Timer_initialize(); |
---|
| 158 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 159 | rtems_semaphore_release( Semaphore_id ); |
---|
| 160 | end_time = Read_timer(); |
---|
| 161 | |
---|
| 162 | put_time( |
---|
[5c491aef] | 163 | "rtems_semaphore_release: task readied -- returns to caller", |
---|
[ac7d5ef0] | 164 | end_time, |
---|
| 165 | OPERATION_COUNT, |
---|
| 166 | 0, |
---|
| 167 | CALLING_OVERHEAD_SEMAPHORE_RELEASE |
---|
| 168 | ); |
---|
| 169 | |
---|
| 170 | name = rtems_build_name( 'T', 'I', 'M', 'E' ); |
---|
| 171 | |
---|
| 172 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 173 | status = rtems_task_delete( Task_id[index] ); |
---|
| 174 | directive_failed( status, "rtems_task_delete" ); |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | Timer_initialize(); |
---|
| 178 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 179 | rtems_task_create( |
---|
| 180 | name, |
---|
| 181 | 10, |
---|
[3652ad35] | 182 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 183 | RTEMS_NO_PREEMPT, |
---|
| 184 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 185 | &Task_id[ index ] |
---|
| 186 | ); |
---|
| 187 | end_time = Read_timer(); |
---|
| 188 | |
---|
| 189 | put_time( |
---|
| 190 | "rtems_task_create", |
---|
| 191 | end_time, |
---|
| 192 | OPERATION_COUNT, |
---|
| 193 | overhead, |
---|
| 194 | CALLING_OVERHEAD_TASK_CREATE |
---|
| 195 | ); |
---|
| 196 | |
---|
| 197 | Timer_initialize(); |
---|
| 198 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 199 | rtems_task_start( Task_id[ index ], Low_tasks, 0 ); |
---|
| 200 | |
---|
| 201 | end_time = Read_timer(); |
---|
| 202 | |
---|
| 203 | put_time( |
---|
| 204 | "rtems_task_start", |
---|
| 205 | end_time, |
---|
| 206 | OPERATION_COUNT, |
---|
| 207 | overhead, |
---|
| 208 | CALLING_OVERHEAD_TASK_START |
---|
| 209 | ); |
---|
| 210 | |
---|
| 211 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 212 | status = rtems_task_delete( Task_id[ index ] ); |
---|
| 213 | directive_failed( status, "rtems_task_delete" ); |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 217 | status = rtems_task_create( |
---|
| 218 | name, |
---|
| 219 | 250, |
---|
[3652ad35] | 220 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 221 | RTEMS_NO_PREEMPT, |
---|
| 222 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 223 | &Task_id[ index ] |
---|
| 224 | ); |
---|
| 225 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
| 226 | |
---|
| 227 | status = rtems_task_start( Task_id[ index ], Restart_task, 0 ); |
---|
| 228 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
| 229 | |
---|
| 230 | status = rtems_task_suspend( Task_id[ index ] ); |
---|
| 231 | directive_failed( status, "rtems_task_suspend LOOP" ); |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | Timer_initialize(); |
---|
| 235 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 236 | (void) rtems_task_restart( Task_id[ index ], 0 ); |
---|
| 237 | end_time = Read_timer(); |
---|
| 238 | |
---|
| 239 | put_time( |
---|
[5c491aef] | 240 | "rtems_task_restart: suspended task -- returns to caller", |
---|
[ac7d5ef0] | 241 | end_time, |
---|
| 242 | OPERATION_COUNT, |
---|
| 243 | overhead, |
---|
| 244 | CALLING_OVERHEAD_TASK_RESTART |
---|
| 245 | ); |
---|
| 246 | |
---|
| 247 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 248 | (void) rtems_task_suspend( Task_id[ index ] ); |
---|
| 249 | |
---|
| 250 | Timer_initialize(); |
---|
| 251 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 252 | (void) rtems_task_delete( Task_id[ index ] ); |
---|
| 253 | end_time = Read_timer(); |
---|
| 254 | |
---|
| 255 | put_time( |
---|
[5c491aef] | 256 | "rtems_task_delete: suspended task", |
---|
[ac7d5ef0] | 257 | end_time, |
---|
| 258 | OPERATION_COUNT, |
---|
| 259 | overhead, |
---|
| 260 | CALLING_OVERHEAD_TASK_DELETE |
---|
| 261 | ); |
---|
| 262 | |
---|
| 263 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 264 | status = rtems_task_create( |
---|
| 265 | name, |
---|
| 266 | 250, |
---|
[3652ad35] | 267 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 268 | RTEMS_DEFAULT_MODES, |
---|
| 269 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 270 | &Task_id[ index ] |
---|
| 271 | ); |
---|
| 272 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
| 273 | |
---|
| 274 | status = rtems_task_start( Task_id[ index ], Restart_task, 0 ); |
---|
| 275 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
| 276 | } |
---|
| 277 | |
---|
| 278 | Timer_initialize(); |
---|
| 279 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 280 | (void) rtems_task_restart( Task_id[ index ], 1 ); |
---|
| 281 | end_time = Read_timer(); |
---|
| 282 | |
---|
| 283 | put_time( |
---|
[5c491aef] | 284 | "rtems_task_restart: ready task -- returns to caller", |
---|
[ac7d5ef0] | 285 | end_time, |
---|
| 286 | OPERATION_COUNT, |
---|
| 287 | overhead, |
---|
| 288 | CALLING_OVERHEAD_TASK_RESTART |
---|
| 289 | ); |
---|
| 290 | |
---|
| 291 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 292 | status = rtems_task_set_priority( Task_id[ index ], 5, &old_priority ); |
---|
| 293 | directive_failed( status, "rtems_task_set_priority loop" ); |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | /* yield processor -- tasks block */ |
---|
| 297 | status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
| 298 | directive_failed( status, "rtems_task_wake_after" ); |
---|
| 299 | |
---|
| 300 | Timer_initialize(); |
---|
| 301 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 302 | (void) rtems_task_restart( Task_id[ index ], 1 ); |
---|
| 303 | end_time = Read_timer(); |
---|
| 304 | |
---|
| 305 | put_time( |
---|
[5c491aef] | 306 | "rtems_task_restart: blocked task -- returns to caller", |
---|
[ac7d5ef0] | 307 | end_time, |
---|
| 308 | OPERATION_COUNT, |
---|
| 309 | overhead, |
---|
| 310 | CALLING_OVERHEAD_TASK_RESTART |
---|
| 311 | ); |
---|
| 312 | |
---|
| 313 | /* yield processor -- tasks block */ |
---|
| 314 | status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
| 315 | directive_failed( status, "rtems_task_wake_after" ); |
---|
| 316 | |
---|
| 317 | Timer_initialize(); |
---|
| 318 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 319 | (void) rtems_task_delete( Task_id[ index ] ); |
---|
| 320 | end_time = Read_timer(); |
---|
| 321 | |
---|
| 322 | put_time( |
---|
[5c491aef] | 323 | "rtems_task_delete: blocked task", |
---|
[ac7d5ef0] | 324 | end_time, |
---|
| 325 | OPERATION_COUNT, |
---|
| 326 | overhead, |
---|
| 327 | CALLING_OVERHEAD_TASK_DELETE |
---|
| 328 | ); |
---|
| 329 | |
---|
[3a4ae6c] | 330 | puts( "*** END OF TEST 4 ***" ); |
---|
[ac7d5ef0] | 331 | exit( 0 ); |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | rtems_task Low_tasks( |
---|
| 335 | rtems_task_argument argument |
---|
| 336 | ) |
---|
| 337 | { |
---|
| 338 | rtems_id id; |
---|
| 339 | rtems_status_code status; |
---|
| 340 | |
---|
| 341 | task_count--; |
---|
| 342 | |
---|
| 343 | if ( task_count == 0 ) { |
---|
| 344 | status = rtems_task_create( |
---|
| 345 | rtems_build_name( 'H', 'I', ' ', ' ' ), |
---|
| 346 | 5, |
---|
[3652ad35] | 347 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 348 | RTEMS_DEFAULT_MODES, |
---|
| 349 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 350 | &id |
---|
| 351 | ); |
---|
| 352 | directive_failed( status, "rtems_task_create HI" ); |
---|
| 353 | |
---|
| 354 | status = rtems_task_start( id, High_task, 0 ); |
---|
| 355 | directive_failed( status, "rtems_task_start HI" ); |
---|
| 356 | |
---|
| 357 | status = rtems_task_create( |
---|
| 358 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
| 359 | 3, |
---|
[3652ad35] | 360 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 361 | RTEMS_DEFAULT_MODES, |
---|
| 362 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 363 | &Highest_id |
---|
| 364 | ); |
---|
| 365 | directive_failed( status, "rtems_task_create HIGH" ); |
---|
| 366 | |
---|
| 367 | status = rtems_task_start( Highest_id, Highest_task, 0 ); |
---|
| 368 | directive_failed( status, "rtems_task_start HIGH" ); |
---|
| 369 | |
---|
| 370 | } |
---|
| 371 | (void) rtems_semaphore_obtain( |
---|
| 372 | Semaphore_id, |
---|
| 373 | RTEMS_DEFAULT_OPTIONS, |
---|
| 374 | RTEMS_NO_TIMEOUT |
---|
| 375 | ); |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | rtems_task Restart_task( |
---|
| 379 | rtems_task_argument argument |
---|
| 380 | ) |
---|
| 381 | { |
---|
| 382 | if ( argument == 1 ) |
---|
| 383 | (void) rtems_semaphore_obtain( |
---|
| 384 | Semaphore_id, |
---|
| 385 | RTEMS_DEFAULT_OPTIONS, |
---|
| 386 | RTEMS_NO_TIMEOUT |
---|
| 387 | ); |
---|
| 388 | } |
---|