[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 | |
---|
| 14 | #include "system.h" |
---|
| 15 | #undef EXTERN |
---|
| 16 | #define EXTERN |
---|
| 17 | #include "conftbl.h" |
---|
| 18 | #include "gvar.h" |
---|
| 19 | |
---|
| 20 | rtems_id Semaphore_id; |
---|
| 21 | rtems_id Task_id[OPERATION_COUNT+1]; |
---|
| 22 | rtems_unsigned32 task_count; |
---|
| 23 | rtems_id Highest_id; |
---|
| 24 | |
---|
| 25 | rtems_task Low_tasks( |
---|
| 26 | rtems_task_argument argument |
---|
| 27 | ); |
---|
| 28 | |
---|
| 29 | rtems_task High_task( |
---|
| 30 | rtems_task_argument argument |
---|
| 31 | ); |
---|
| 32 | |
---|
| 33 | rtems_task Restart_task( |
---|
| 34 | rtems_task_argument argument |
---|
| 35 | ); |
---|
| 36 | |
---|
| 37 | void test_init(); |
---|
| 38 | |
---|
| 39 | rtems_task Init( |
---|
| 40 | rtems_task_argument argument |
---|
| 41 | ) |
---|
| 42 | { |
---|
| 43 | rtems_status_code status; |
---|
| 44 | |
---|
| 45 | puts( "\n\n*** TIME TEST 4 ***" ); |
---|
| 46 | |
---|
| 47 | test_init(); |
---|
| 48 | |
---|
| 49 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 50 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | void test_init() |
---|
| 54 | { |
---|
| 55 | rtems_status_code status; |
---|
| 56 | rtems_unsigned32 index; |
---|
| 57 | |
---|
| 58 | task_count = OPERATION_COUNT; |
---|
| 59 | |
---|
| 60 | for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 61 | |
---|
| 62 | status = rtems_task_create( |
---|
| 63 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
| 64 | 10, |
---|
| 65 | 1024, |
---|
| 66 | RTEMS_NO_PREEMPT, |
---|
| 67 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 68 | &Task_id[ index ] |
---|
| 69 | ); |
---|
| 70 | directive_failed( status, "rtems_task_create loop" ); |
---|
| 71 | |
---|
| 72 | status = rtems_task_start( Task_id[ index ], Low_tasks, 0 ); |
---|
| 73 | directive_failed( status, "rtems_task_start loop" ); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | status = rtems_semaphore_create( |
---|
| 77 | rtems_build_name( 'S', 'M', '1', ' ' ), |
---|
| 78 | 0, |
---|
| 79 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 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( |
---|
| 97 | "rtems_task_restart (blocked, preempt)", |
---|
| 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( |
---|
| 116 | "rtems_task_restart (ready, preempt)", |
---|
| 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( |
---|
| 163 | "rtems_semaphore_release (readying)", |
---|
| 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, |
---|
| 182 | 1024, |
---|
| 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, |
---|
| 220 | 1024, |
---|
| 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( |
---|
| 240 | "rtems_task_restart (suspended)", |
---|
| 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( |
---|
| 256 | "rtems_task_delete (suspended)", |
---|
| 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, |
---|
| 267 | 1024, |
---|
| 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( |
---|
| 284 | "rtems_task_restart (ready)", |
---|
| 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( |
---|
| 306 | "rtems_task_restart (blocked, no preempt)", |
---|
| 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( |
---|
| 323 | "rtems_task_delete (blocked)", |
---|
| 324 | end_time, |
---|
| 325 | OPERATION_COUNT, |
---|
| 326 | overhead, |
---|
| 327 | CALLING_OVERHEAD_TASK_DELETE |
---|
| 328 | ); |
---|
| 329 | |
---|
| 330 | exit( 0 ); |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | rtems_task Low_tasks( |
---|
| 334 | rtems_task_argument argument |
---|
| 335 | ) |
---|
| 336 | { |
---|
| 337 | rtems_id id; |
---|
| 338 | rtems_status_code status; |
---|
| 339 | |
---|
| 340 | task_count--; |
---|
| 341 | |
---|
| 342 | if ( task_count == 0 ) { |
---|
| 343 | status = rtems_task_create( |
---|
| 344 | rtems_build_name( 'H', 'I', ' ', ' ' ), |
---|
| 345 | 5, |
---|
| 346 | 2048, |
---|
| 347 | RTEMS_DEFAULT_MODES, |
---|
| 348 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 349 | &id |
---|
| 350 | ); |
---|
| 351 | directive_failed( status, "rtems_task_create HI" ); |
---|
| 352 | |
---|
| 353 | status = rtems_task_start( id, High_task, 0 ); |
---|
| 354 | directive_failed( status, "rtems_task_start HI" ); |
---|
| 355 | |
---|
| 356 | status = rtems_task_create( |
---|
| 357 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
| 358 | 3, |
---|
| 359 | 2048, |
---|
| 360 | RTEMS_DEFAULT_MODES, |
---|
| 361 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 362 | &Highest_id |
---|
| 363 | ); |
---|
| 364 | directive_failed( status, "rtems_task_create HIGH" ); |
---|
| 365 | |
---|
| 366 | status = rtems_task_start( Highest_id, Highest_task, 0 ); |
---|
| 367 | directive_failed( status, "rtems_task_start HIGH" ); |
---|
| 368 | |
---|
| 369 | } |
---|
| 370 | (void) rtems_semaphore_obtain( |
---|
| 371 | Semaphore_id, |
---|
| 372 | RTEMS_DEFAULT_OPTIONS, |
---|
| 373 | RTEMS_NO_TIMEOUT |
---|
| 374 | ); |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | rtems_task Restart_task( |
---|
| 378 | rtems_task_argument argument |
---|
| 379 | ) |
---|
| 380 | { |
---|
| 381 | if ( argument == 1 ) |
---|
| 382 | (void) rtems_semaphore_obtain( |
---|
| 383 | Semaphore_id, |
---|
| 384 | RTEMS_DEFAULT_OPTIONS, |
---|
| 385 | RTEMS_NO_TIMEOUT |
---|
| 386 | ); |
---|
| 387 | } |
---|