[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 <rtems.h> |
---|
| 15 | #include "system.h" |
---|
| 16 | #include "fptest.h" |
---|
| 17 | #include "coverhd.h" |
---|
| 18 | #include "tmacros.h" |
---|
| 19 | #include "timesys.h" |
---|
| 20 | |
---|
| 21 | #undef EXTERN |
---|
| 22 | #define EXTERN |
---|
| 23 | #include "gvar.h" |
---|
| 24 | #include "conftbl.h" |
---|
| 25 | #undef EXTERN |
---|
| 26 | #define EXTERN extern |
---|
| 27 | |
---|
| 28 | /* TEST DATA */ |
---|
| 29 | rtems_id Semaphore_id; |
---|
| 30 | |
---|
| 31 | Objects_Locations location; /* uses internal RTEMS type */ |
---|
| 32 | |
---|
| 33 | Thread_Control *Middle_tcb; /* uses internal RTEMS type */ |
---|
| 34 | |
---|
| 35 | rtems_task High_task( |
---|
| 36 | rtems_task_argument argument |
---|
| 37 | ); |
---|
| 38 | |
---|
| 39 | rtems_task Middle_task( |
---|
| 40 | rtems_task_argument argument |
---|
| 41 | ); |
---|
| 42 | |
---|
| 43 | rtems_task Low_task( |
---|
| 44 | rtems_task_argument argument |
---|
| 45 | ); |
---|
| 46 | |
---|
| 47 | rtems_task Floating_point_task_1( |
---|
| 48 | rtems_task_argument argument |
---|
| 49 | ); |
---|
| 50 | |
---|
| 51 | rtems_task Floating_point_task_2( |
---|
| 52 | rtems_task_argument argument |
---|
| 53 | ); |
---|
| 54 | |
---|
| 55 | void complete_test( void ); |
---|
| 56 | |
---|
| 57 | rtems_task null_task( |
---|
| 58 | rtems_task_argument argument |
---|
| 59 | ) |
---|
| 60 | { |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | rtems_task Init( |
---|
| 64 | rtems_task_argument argument |
---|
| 65 | ) |
---|
| 66 | { |
---|
| 67 | rtems_unsigned32 index; |
---|
| 68 | rtems_id task_id; |
---|
| 69 | rtems_status_code status; |
---|
| 70 | |
---|
| 71 | puts( "\n\n*** TIME TEST 26 ***" ); |
---|
| 72 | |
---|
| 73 | status = rtems_task_create( |
---|
| 74 | rtems_build_name( 'F', 'P', '1', ' ' ), |
---|
| 75 | 201, |
---|
| 76 | 2048, |
---|
| 77 | RTEMS_DEFAULT_MODES, |
---|
| 78 | RTEMS_FLOATING_POINT, |
---|
| 79 | &task_id |
---|
| 80 | ); |
---|
| 81 | directive_failed( status, "rtems_task_create of FP1" ); |
---|
| 82 | |
---|
| 83 | status = rtems_task_start( task_id, Floating_point_task_1, 0 ); |
---|
| 84 | directive_failed( status, "rtems_task_start of FP1" ); |
---|
| 85 | |
---|
| 86 | status = rtems_task_create( |
---|
| 87 | rtems_build_name( 'F', 'P', '2', ' ' ), |
---|
| 88 | 202, |
---|
| 89 | 2048, |
---|
| 90 | RTEMS_DEFAULT_MODES, |
---|
| 91 | RTEMS_FLOATING_POINT, |
---|
| 92 | &task_id |
---|
| 93 | ); |
---|
| 94 | directive_failed( status, "rtems_task_create of FP2" ); |
---|
| 95 | |
---|
| 96 | status = rtems_task_start( task_id, Floating_point_task_2, 0 ); |
---|
| 97 | directive_failed( status, "rtems_task_start of FP2" ); |
---|
| 98 | |
---|
| 99 | status = rtems_task_create( |
---|
| 100 | rtems_build_name( 'L', 'O', 'W', ' ' ), |
---|
| 101 | 200, |
---|
| 102 | 2048, |
---|
| 103 | RTEMS_DEFAULT_MODES, |
---|
| 104 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 105 | &task_id |
---|
| 106 | ); |
---|
| 107 | directive_failed( status, "rtems_task_create of LOW" ); |
---|
| 108 | |
---|
| 109 | status = rtems_task_start( task_id, Low_task, 0 ); |
---|
| 110 | directive_failed( status, "rtems_task_start of LOW" ); |
---|
| 111 | |
---|
| 112 | status = rtems_task_create( |
---|
| 113 | rtems_build_name( 'M', 'I', 'D', ' ' ), |
---|
| 114 | 128, |
---|
| 115 | 2048, |
---|
| 116 | RTEMS_DEFAULT_MODES, |
---|
| 117 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 118 | &task_id |
---|
| 119 | ); |
---|
| 120 | directive_failed( status, "rtems_task_create of MIDDLE" ); |
---|
| 121 | |
---|
| 122 | status = rtems_task_start( task_id, Middle_task, 0 ); |
---|
| 123 | directive_failed( status, "rtems_task_start of MIDDLE" ); |
---|
| 124 | |
---|
| 125 | status = rtems_task_create( |
---|
| 126 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
| 127 | 5, |
---|
| 128 | 2048, |
---|
| 129 | RTEMS_DEFAULT_MODES, |
---|
| 130 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 131 | &task_id |
---|
| 132 | ); |
---|
| 133 | directive_failed( status, "rtems_task_create of HIGH" ); |
---|
| 134 | |
---|
| 135 | status = rtems_task_start( task_id, High_task, 0 ); |
---|
| 136 | directive_failed( status, "rtems_task_start of HIGH" ); |
---|
| 137 | |
---|
| 138 | status = rtems_semaphore_create( |
---|
| 139 | rtems_build_name( 'S', 'E', 'M', '1' ), |
---|
| 140 | OPERATION_COUNT, |
---|
| 141 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 142 | &Semaphore_id |
---|
| 143 | ); |
---|
| 144 | directive_failed( status, "rtems_semaphore_create" ); |
---|
| 145 | |
---|
| 146 | for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 147 | status = rtems_task_create( |
---|
| 148 | rtems_build_name( 'N', 'U', 'L', 'L' ), |
---|
| 149 | 254, |
---|
| 150 | 1024, |
---|
| 151 | RTEMS_DEFAULT_MODES, |
---|
| 152 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 153 | &task_id |
---|
| 154 | ); |
---|
| 155 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
| 156 | |
---|
| 157 | status = rtems_task_start( task_id, null_task, 0 ); |
---|
| 158 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 162 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | rtems_task High_task( |
---|
| 166 | rtems_task_argument argument |
---|
| 167 | ) |
---|
| 168 | { |
---|
| 169 | Timer_initialize(); |
---|
| 170 | _Thread_Disable_dispatch(); |
---|
| 171 | end_time = Read_timer(); |
---|
| 172 | |
---|
| 173 | put_time( |
---|
| 174 | "THREAD_DISABLE_DISPATCH", |
---|
| 175 | end_time, |
---|
| 176 | 1, |
---|
| 177 | 0, |
---|
| 178 | 0 |
---|
| 179 | ); |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | Timer_initialize(); |
---|
| 183 | _Thread_Enable_dispatch(); |
---|
| 184 | end_time = Read_timer(); |
---|
| 185 | |
---|
| 186 | put_time( |
---|
| 187 | "THREAD_ENABLE_DISPATCH", |
---|
| 188 | end_time, |
---|
| 189 | 1, |
---|
| 190 | 0, |
---|
| 191 | 0 |
---|
| 192 | ); |
---|
| 193 | |
---|
| 194 | Timer_initialize(); |
---|
| 195 | _Thread_Set_state( _Thread_Executing, STATES_SUSPENDED ); |
---|
| 196 | end_time = Read_timer(); |
---|
| 197 | |
---|
| 198 | put_time( |
---|
| 199 | "THREAD_SET_STATE", |
---|
| 200 | end_time, |
---|
| 201 | 1, |
---|
| 202 | 0, |
---|
| 203 | 0 |
---|
| 204 | ); |
---|
| 205 | |
---|
| 206 | _Context_Switch_necessary = TRUE; |
---|
| 207 | |
---|
| 208 | Timer_initialize(); |
---|
| 209 | _Thread_Dispatch(); /* dispatches Middle_task */ |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | rtems_task Middle_task( |
---|
| 213 | rtems_task_argument argument |
---|
| 214 | ) |
---|
| 215 | { |
---|
| 216 | end_time = Read_timer(); |
---|
| 217 | |
---|
| 218 | put_time( |
---|
| 219 | "THREAD_DISPATCH (NO FP)", |
---|
| 220 | end_time, |
---|
| 221 | 1, |
---|
| 222 | 0, |
---|
| 223 | 0 |
---|
| 224 | ); |
---|
| 225 | |
---|
| 226 | _Thread_Set_state( _Thread_Executing, STATES_SUSPENDED ); |
---|
| 227 | |
---|
| 228 | Middle_tcb = _Thread_Executing; |
---|
| 229 | |
---|
| 230 | _Thread_Executing = |
---|
| 231 | (Thread_Control *) _Thread_Ready_chain[200].first; |
---|
| 232 | |
---|
| 233 | /* do not force context switch */ |
---|
| 234 | |
---|
| 235 | _Context_Switch_necessary = FALSE; |
---|
| 236 | |
---|
| 237 | Timer_initialize(); |
---|
| 238 | _Context_Switch( &Middle_tcb->Registers, &_Thread_Executing->Registers ); |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | rtems_task Low_task( |
---|
| 242 | rtems_task_argument argument |
---|
| 243 | ) |
---|
| 244 | { |
---|
| 245 | Thread_Control *executing; |
---|
| 246 | |
---|
| 247 | end_time = Read_timer(); |
---|
| 248 | |
---|
| 249 | put_time( |
---|
| 250 | "CONTEXT_SWITCH (NO FP)", |
---|
| 251 | end_time, |
---|
| 252 | 1, |
---|
| 253 | 0, |
---|
| 254 | 0 |
---|
| 255 | ); |
---|
| 256 | |
---|
| 257 | executing = _Thread_Executing; |
---|
| 258 | |
---|
| 259 | _Thread_Executing = |
---|
| 260 | (Thread_Control *) _Thread_Ready_chain[201].first; |
---|
| 261 | |
---|
| 262 | /* do not force context switch */ |
---|
| 263 | |
---|
| 264 | _Context_Switch_necessary = FALSE; |
---|
| 265 | |
---|
| 266 | Timer_initialize(); |
---|
| 267 | _Context_Restore_fp( &_Thread_Executing->fp_context ); |
---|
| 268 | _Context_Switch( &executing->Registers, &_Thread_Executing->Registers ); |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | rtems_task Floating_point_task_1( |
---|
| 272 | rtems_task_argument argument |
---|
| 273 | ) |
---|
| 274 | { |
---|
| 275 | Thread_Control *executing; |
---|
| 276 | FP_DECLARE; |
---|
| 277 | |
---|
| 278 | end_time = Read_timer(); |
---|
| 279 | |
---|
| 280 | put_time( |
---|
| 281 | "CONTEXT_SWITCH (restore 1st FP)", |
---|
| 282 | end_time, |
---|
| 283 | 1, |
---|
| 284 | 0, |
---|
| 285 | 0 |
---|
| 286 | ); |
---|
| 287 | |
---|
| 288 | executing = _Thread_Executing; |
---|
| 289 | |
---|
| 290 | _Thread_Executing = |
---|
| 291 | (Thread_Control *) _Thread_Ready_chain[202].first; |
---|
| 292 | |
---|
| 293 | /* do not force context switch */ |
---|
| 294 | |
---|
| 295 | _Context_Switch_necessary = FALSE; |
---|
| 296 | |
---|
| 297 | Timer_initialize(); |
---|
| 298 | _Context_Save_fp( &executing->fp_context ); |
---|
| 299 | _Context_Restore_fp( &_Thread_Executing->fp_context ); |
---|
| 300 | _Context_Switch( &executing->Registers, &_Thread_Executing->Registers ); |
---|
| 301 | /* switch to Floating_point_task_2 */ |
---|
| 302 | |
---|
| 303 | end_time = Read_timer(); |
---|
| 304 | |
---|
| 305 | put_time( |
---|
| 306 | "CONTEXT_SWITCH (used->init FP)", |
---|
| 307 | end_time, |
---|
| 308 | 1, |
---|
| 309 | 0, |
---|
| 310 | 0 |
---|
| 311 | ); |
---|
| 312 | |
---|
| 313 | FP_LOAD( 1.0 ); |
---|
| 314 | |
---|
| 315 | executing = _Thread_Executing; |
---|
| 316 | |
---|
| 317 | _Thread_Executing = |
---|
| 318 | (Thread_Control *) _Thread_Ready_chain[202].first; |
---|
| 319 | |
---|
| 320 | /* do not force context switch */ |
---|
| 321 | |
---|
| 322 | _Context_Switch_necessary = FALSE; |
---|
| 323 | |
---|
| 324 | Timer_initialize(); |
---|
| 325 | _Context_Save_fp( &executing->fp_context ); |
---|
| 326 | _Context_Restore_fp( &_Thread_Executing->fp_context ); |
---|
| 327 | _Context_Switch( &executing->Registers, &_Thread_Executing->Registers ); |
---|
| 328 | /* switch to Floating_point_task_2 */ |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | rtems_task Floating_point_task_2( |
---|
| 332 | rtems_task_argument argument |
---|
| 333 | ) |
---|
| 334 | { |
---|
| 335 | Thread_Control *executing; |
---|
| 336 | FP_DECLARE; |
---|
| 337 | |
---|
| 338 | end_time = Read_timer(); |
---|
| 339 | |
---|
| 340 | put_time( |
---|
| 341 | "CONTEXT_SWITCH (init->init FP)", |
---|
| 342 | end_time, |
---|
| 343 | 1, |
---|
| 344 | 0, |
---|
| 345 | 0 |
---|
| 346 | ); |
---|
| 347 | |
---|
| 348 | executing = _Thread_Executing; |
---|
| 349 | |
---|
| 350 | _Thread_Executing = |
---|
| 351 | (Thread_Control *) _Thread_Ready_chain[201].first; |
---|
| 352 | |
---|
| 353 | FP_LOAD( 1.0 ); |
---|
| 354 | |
---|
| 355 | /* do not force context switch */ |
---|
| 356 | |
---|
| 357 | _Context_Switch_necessary = FALSE; |
---|
| 358 | |
---|
| 359 | Timer_initialize(); |
---|
| 360 | _Context_Save_fp( &executing->fp_context ); |
---|
| 361 | _Context_Restore_fp( &_Thread_Executing->fp_context ); |
---|
| 362 | _Context_Switch( &executing->Registers, &_Thread_Executing->Registers ); |
---|
| 363 | /* switch to Floating_point_task_1 */ |
---|
| 364 | |
---|
| 365 | end_time = Read_timer(); |
---|
| 366 | |
---|
| 367 | put_time( |
---|
| 368 | "CONTEXT_SWITCH (used->used FP)", |
---|
| 369 | end_time, |
---|
| 370 | 1, |
---|
| 371 | 0, |
---|
| 372 | 0 |
---|
| 373 | ); |
---|
| 374 | |
---|
| 375 | complete_test(); |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | void complete_test( void ) |
---|
| 379 | { |
---|
| 380 | rtems_unsigned32 index; |
---|
| 381 | rtems_id task_id; |
---|
| 382 | |
---|
| 383 | Timer_initialize(); |
---|
| 384 | _Thread_Resume( Middle_tcb ); |
---|
| 385 | end_time = Read_timer(); |
---|
| 386 | |
---|
| 387 | put_time( |
---|
| 388 | "THREAD_RESUME", |
---|
| 389 | end_time, |
---|
| 390 | 1, |
---|
| 391 | 0, |
---|
| 392 | 0 |
---|
| 393 | ); |
---|
| 394 | |
---|
| 395 | _Thread_Set_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE ); |
---|
| 396 | |
---|
| 397 | Timer_initialize(); |
---|
| 398 | _Thread_Unblock( Middle_tcb ); |
---|
| 399 | end_time = Read_timer(); |
---|
| 400 | |
---|
| 401 | put_time( |
---|
| 402 | "THREAD_UNBLOCK", |
---|
| 403 | end_time, |
---|
| 404 | 1, |
---|
| 405 | 0, |
---|
| 406 | 0 |
---|
| 407 | ); |
---|
| 408 | |
---|
| 409 | _Thread_Set_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE ); |
---|
| 410 | |
---|
| 411 | Timer_initialize(); |
---|
| 412 | _Thread_Ready( Middle_tcb ); |
---|
| 413 | end_time = Read_timer(); |
---|
| 414 | |
---|
| 415 | put_time( |
---|
| 416 | "THREAD_READY", |
---|
| 417 | end_time, |
---|
| 418 | 1, |
---|
| 419 | 0, |
---|
| 420 | 0 |
---|
| 421 | ); |
---|
| 422 | |
---|
| 423 | Timer_initialize(); |
---|
| 424 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 425 | (void) Empty_function(); |
---|
| 426 | overhead = Read_timer(); |
---|
| 427 | |
---|
| 428 | task_id = Middle_tcb->Object.id; |
---|
| 429 | |
---|
| 430 | Timer_initialize(); |
---|
| 431 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 432 | (void) _Thread_Get( task_id, &location ); |
---|
| 433 | end_time = Read_timer(); |
---|
| 434 | |
---|
| 435 | put_time( |
---|
| 436 | "THREAD_GET", |
---|
| 437 | end_time, |
---|
| 438 | OPERATION_COUNT, |
---|
| 439 | 0, |
---|
| 440 | 0 |
---|
| 441 | ); |
---|
| 442 | |
---|
| 443 | Timer_initialize(); |
---|
| 444 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 445 | (void) _Semaphore_Get( Semaphore_id, &location ); |
---|
| 446 | end_time = Read_timer(); |
---|
| 447 | |
---|
| 448 | put_time( |
---|
| 449 | "SEMAPHORE_GET", |
---|
| 450 | end_time, |
---|
| 451 | OPERATION_COUNT, |
---|
| 452 | 0, |
---|
| 453 | 0 |
---|
| 454 | ); |
---|
| 455 | |
---|
| 456 | Timer_initialize(); |
---|
| 457 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 458 | (void) _Thread_Get( 0x3, &location ); |
---|
| 459 | end_time = Read_timer(); |
---|
| 460 | |
---|
| 461 | put_time( |
---|
| 462 | "THREAD_GET invalid id", |
---|
| 463 | end_time, |
---|
| 464 | OPERATION_COUNT, |
---|
| 465 | 0, |
---|
| 466 | 0 |
---|
| 467 | ); |
---|
| 468 | exit( 0 ); |
---|
| 469 | } |
---|
| 470 | |
---|