[ac7d5ef0] | 1 | /* |
---|
[9410d011] | 2 | * COPYRIGHT (c) 1989-2013. |
---|
[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 |
---|
[c499856] | 7 | * http://www.rtems.org/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 <rtems.h> |
---|
| 16 | #include "system.h" |
---|
| 17 | #include "fptest.h" |
---|
[459f770] | 18 | #include <coverhd.h> |
---|
| 19 | #include <tmacros.h> |
---|
| 20 | #include <timesys.h> |
---|
[ac7d5ef0] | 21 | |
---|
[494c2e3] | 22 | #include <rtems/score/schedulerpriorityimpl.h> |
---|
[2bbea657] | 23 | #include <rtems/rtems/semimpl.h> |
---|
[ac7d5ef0] | 24 | |
---|
[bf30999] | 25 | #if defined( RTEMS_SMP ) && defined( RTEMS_DEBUG ) |
---|
| 26 | #define PREVENT_SMP_ASSERT_FAILURES |
---|
| 27 | #endif |
---|
| 28 | |
---|
[2ead50a] | 29 | const char rtems_test_name[] = "TIME TEST 26"; |
---|
| 30 | |
---|
[ac7d5ef0] | 31 | /* TEST DATA */ |
---|
| 32 | rtems_id Semaphore_id; |
---|
| 33 | |
---|
| 34 | Thread_Control *Middle_tcb; /* uses internal RTEMS type */ |
---|
| 35 | |
---|
[7950309] | 36 | Thread_Control *Low_tcb; /* uses internal RTEMS type */ |
---|
| 37 | |
---|
[2617b345] | 38 | /* |
---|
| 39 | * Variables to hold execution times until they are printed |
---|
| 40 | * at the end of the test. |
---|
| 41 | */ |
---|
| 42 | |
---|
[0720ff4] | 43 | uint32_t isr_disable_time; |
---|
| 44 | uint32_t isr_flash_time; |
---|
| 45 | uint32_t isr_enable_time; |
---|
| 46 | uint32_t thread_disable_dispatch_time; |
---|
| 47 | uint32_t thread_enable_dispatch_time; |
---|
| 48 | uint32_t thread_set_state_time; |
---|
| 49 | uint32_t thread_dispatch_no_fp_time; |
---|
| 50 | uint32_t context_switch_no_fp_time; |
---|
| 51 | uint32_t context_switch_self_time; |
---|
| 52 | uint32_t context_switch_another_task_time; |
---|
| 53 | uint32_t context_switch_restore_1st_fp_time; |
---|
| 54 | uint32_t context_switch_save_idle_restore_initted_time; |
---|
| 55 | uint32_t context_switch_save_restore_idle_time; |
---|
| 56 | uint32_t context_switch_save_restore_initted_time; |
---|
| 57 | uint32_t thread_resume_time; |
---|
| 58 | uint32_t thread_unblock_time; |
---|
| 59 | uint32_t thread_ready_time; |
---|
| 60 | uint32_t thread_get_time; |
---|
| 61 | uint32_t semaphore_get_time; |
---|
| 62 | uint32_t thread_get_invalid_time; |
---|
[2617b345] | 63 | |
---|
[1055ce20] | 64 | rtems_task null_task( |
---|
| 65 | rtems_task_argument argument |
---|
| 66 | ); |
---|
| 67 | |
---|
[ac7d5ef0] | 68 | rtems_task High_task( |
---|
| 69 | rtems_task_argument argument |
---|
| 70 | ); |
---|
| 71 | |
---|
| 72 | rtems_task Middle_task( |
---|
| 73 | rtems_task_argument argument |
---|
| 74 | ); |
---|
| 75 | |
---|
| 76 | rtems_task Low_task( |
---|
| 77 | rtems_task_argument argument |
---|
| 78 | ); |
---|
| 79 | |
---|
| 80 | rtems_task Floating_point_task_1( |
---|
| 81 | rtems_task_argument argument |
---|
| 82 | ); |
---|
| 83 | |
---|
| 84 | rtems_task Floating_point_task_2( |
---|
| 85 | rtems_task_argument argument |
---|
| 86 | ); |
---|
| 87 | |
---|
| 88 | void complete_test( void ); |
---|
| 89 | |
---|
[e31a9c8] | 90 | static void set_thread_dispatch_necessary( bool dispatch_necessary ) |
---|
| 91 | { |
---|
[bf30999] | 92 | #if defined( PREVENT_SMP_ASSERT_FAILURES ) |
---|
| 93 | ISR_Level level; |
---|
[e31a9c8] | 94 | |
---|
[4b04cb61] | 95 | _ISR_Local_disable( level ); |
---|
[e31a9c8] | 96 | #endif |
---|
| 97 | |
---|
| 98 | _Thread_Dispatch_necessary = dispatch_necessary; |
---|
| 99 | |
---|
[222dc775] | 100 | if ( !dispatch_necessary ) { |
---|
| 101 | _Thread_Heir = _Thread_Executing; |
---|
| 102 | } |
---|
| 103 | |
---|
[bf30999] | 104 | #if defined( PREVENT_SMP_ASSERT_FAILURES ) |
---|
[4b04cb61] | 105 | _ISR_Local_enable( level ); |
---|
[e31a9c8] | 106 | #endif |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | static void set_thread_heir( Thread_Control *thread ) |
---|
| 110 | { |
---|
[bf30999] | 111 | #if defined( PREVENT_SMP_ASSERT_FAILURES ) |
---|
| 112 | ISR_Level level; |
---|
[e31a9c8] | 113 | |
---|
[4b04cb61] | 114 | _ISR_Local_disable( level ); |
---|
[e31a9c8] | 115 | #endif |
---|
| 116 | |
---|
| 117 | _Thread_Heir = thread; |
---|
| 118 | |
---|
[bf30999] | 119 | #if defined( PREVENT_SMP_ASSERT_FAILURES ) |
---|
[4b04cb61] | 120 | _ISR_Local_enable( level ); |
---|
[e31a9c8] | 121 | #endif |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | static void set_thread_executing( Thread_Control *thread ) |
---|
| 125 | { |
---|
[bf30999] | 126 | #if defined( PREVENT_SMP_ASSERT_FAILURES ) |
---|
| 127 | ISR_Level level; |
---|
[e31a9c8] | 128 | |
---|
[4b04cb61] | 129 | _ISR_Local_disable( level ); |
---|
[e31a9c8] | 130 | #endif |
---|
| 131 | |
---|
| 132 | _Thread_Executing = thread; |
---|
| 133 | |
---|
[bf30999] | 134 | #if defined( PREVENT_SMP_ASSERT_FAILURES ) |
---|
[4b04cb61] | 135 | _ISR_Local_enable( level ); |
---|
[e31a9c8] | 136 | #endif |
---|
| 137 | } |
---|
| 138 | |
---|
[bf30999] | 139 | static void thread_resume( Thread_Control *thread ) |
---|
| 140 | { |
---|
[edcf89b] | 141 | _Thread_Clear_state( thread, STATES_SUSPENDED ); |
---|
[bf30999] | 142 | } |
---|
| 143 | |
---|
[ac7d5ef0] | 144 | rtems_task null_task( |
---|
| 145 | rtems_task_argument argument |
---|
| 146 | ) |
---|
| 147 | { |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | rtems_task Init( |
---|
| 151 | rtems_task_argument argument |
---|
| 152 | ) |
---|
| 153 | { |
---|
[0720ff4] | 154 | uint32_t index; |
---|
[ac7d5ef0] | 155 | rtems_id task_id; |
---|
| 156 | rtems_status_code status; |
---|
| 157 | |
---|
[3a4ae6c] | 158 | Print_Warning(); |
---|
| 159 | |
---|
[2ead50a] | 160 | TEST_BEGIN(); |
---|
[ac7d5ef0] | 161 | |
---|
[e1598a6] | 162 | if ( |
---|
| 163 | _Scheduler_Table[ 0 ].Operations.initialize |
---|
| 164 | != _Scheduler_priority_Initialize |
---|
| 165 | ) { |
---|
[a1a5f92] | 166 | puts(" Error ==> " ); |
---|
| 167 | puts("Test only supported for deterministic priority scheduler\n" ); |
---|
[2ead50a] | 168 | TEST_END(); |
---|
[a1a5f92] | 169 | rtems_test_exit( 0 ); |
---|
| 170 | } |
---|
| 171 | |
---|
[1055ce20] | 172 | #define FP1_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 3u) /* 201, */ |
---|
[ac7d5ef0] | 173 | status = rtems_task_create( |
---|
| 174 | rtems_build_name( 'F', 'P', '1', ' ' ), |
---|
[4389287a] | 175 | FP1_PRIORITY, |
---|
[3652ad35] | 176 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 177 | RTEMS_DEFAULT_MODES, |
---|
| 178 | RTEMS_FLOATING_POINT, |
---|
| 179 | &task_id |
---|
| 180 | ); |
---|
| 181 | directive_failed( status, "rtems_task_create of FP1" ); |
---|
| 182 | |
---|
| 183 | status = rtems_task_start( task_id, Floating_point_task_1, 0 ); |
---|
| 184 | directive_failed( status, "rtems_task_start of FP1" ); |
---|
| 185 | |
---|
[1055ce20] | 186 | #define FP2_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 2u) /* 202, */ |
---|
[ac7d5ef0] | 187 | status = rtems_task_create( |
---|
| 188 | rtems_build_name( 'F', 'P', '2', ' ' ), |
---|
[4389287a] | 189 | FP2_PRIORITY, |
---|
[3652ad35] | 190 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 191 | RTEMS_DEFAULT_MODES, |
---|
| 192 | RTEMS_FLOATING_POINT, |
---|
| 193 | &task_id |
---|
| 194 | ); |
---|
| 195 | directive_failed( status, "rtems_task_create of FP2" ); |
---|
| 196 | |
---|
| 197 | status = rtems_task_start( task_id, Floating_point_task_2, 0 ); |
---|
| 198 | directive_failed( status, "rtems_task_start of FP2" ); |
---|
| 199 | |
---|
[1055ce20] | 200 | #define LOW_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 4u) /* 200, */ |
---|
[ac7d5ef0] | 201 | status = rtems_task_create( |
---|
| 202 | rtems_build_name( 'L', 'O', 'W', ' ' ), |
---|
[4389287a] | 203 | LOW_PRIORITY, |
---|
[3652ad35] | 204 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 205 | RTEMS_DEFAULT_MODES, |
---|
| 206 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 207 | &task_id |
---|
| 208 | ); |
---|
| 209 | directive_failed( status, "rtems_task_create of LOW" ); |
---|
| 210 | |
---|
| 211 | status = rtems_task_start( task_id, Low_task, 0 ); |
---|
| 212 | directive_failed( status, "rtems_task_start of LOW" ); |
---|
| 213 | |
---|
[1055ce20] | 214 | #define MIDDLE_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 5u) /* 128, */ |
---|
[ac7d5ef0] | 215 | status = rtems_task_create( |
---|
| 216 | rtems_build_name( 'M', 'I', 'D', ' ' ), |
---|
[4389287a] | 217 | MIDDLE_PRIORITY, |
---|
[3652ad35] | 218 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 219 | RTEMS_DEFAULT_MODES, |
---|
| 220 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 221 | &task_id |
---|
| 222 | ); |
---|
| 223 | directive_failed( status, "rtems_task_create of MIDDLE" ); |
---|
| 224 | |
---|
| 225 | status = rtems_task_start( task_id, Middle_task, 0 ); |
---|
| 226 | directive_failed( status, "rtems_task_start of MIDDLE" ); |
---|
| 227 | |
---|
| 228 | status = rtems_task_create( |
---|
| 229 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
| 230 | 5, |
---|
[3652ad35] | 231 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 232 | RTEMS_DEFAULT_MODES, |
---|
| 233 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 234 | &task_id |
---|
| 235 | ); |
---|
| 236 | directive_failed( status, "rtems_task_create of HIGH" ); |
---|
| 237 | |
---|
| 238 | status = rtems_task_start( task_id, High_task, 0 ); |
---|
| 239 | directive_failed( status, "rtems_task_start of HIGH" ); |
---|
| 240 | |
---|
| 241 | status = rtems_semaphore_create( |
---|
| 242 | rtems_build_name( 'S', 'E', 'M', '1' ), |
---|
| 243 | OPERATION_COUNT, |
---|
| 244 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
[7f6a24ab] | 245 | RTEMS_NO_PRIORITY, |
---|
[ac7d5ef0] | 246 | &Semaphore_id |
---|
| 247 | ); |
---|
| 248 | directive_failed( status, "rtems_semaphore_create" ); |
---|
| 249 | |
---|
| 250 | for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 251 | status = rtems_task_create( |
---|
| 252 | rtems_build_name( 'N', 'U', 'L', 'L' ), |
---|
[1055ce20] | 253 | RTEMS_MAXIMUM_PRIORITY - 1u, /* 254, */ |
---|
[3652ad35] | 254 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 255 | RTEMS_DEFAULT_MODES, |
---|
| 256 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 257 | &task_id |
---|
| 258 | ); |
---|
| 259 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
| 260 | |
---|
| 261 | status = rtems_task_start( task_id, null_task, 0 ); |
---|
| 262 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 266 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | rtems_task High_task( |
---|
| 270 | rtems_task_argument argument |
---|
| 271 | ) |
---|
| 272 | { |
---|
[7950309] | 273 | rtems_interrupt_level level; |
---|
| 274 | |
---|
[dab902d5] | 275 | _Thread_Dispatch_disable(); |
---|
[bf30999] | 276 | |
---|
[dbf4f17] | 277 | benchmark_timer_initialize(); |
---|
[cdf30f05] | 278 | rtems_interrupt_local_disable( level ); |
---|
[dbf4f17] | 279 | isr_disable_time = benchmark_timer_read(); |
---|
[8f71a36] | 280 | |
---|
[dbf4f17] | 281 | benchmark_timer_initialize(); |
---|
[cdf30f05] | 282 | #if defined(RTEMS_SMP) |
---|
| 283 | rtems_interrupt_local_enable( level ); |
---|
| 284 | rtems_interrupt_local_disable( level ); |
---|
| 285 | #else |
---|
[7950309] | 286 | rtems_interrupt_flash( level ); |
---|
[cdf30f05] | 287 | #endif |
---|
[dbf4f17] | 288 | isr_flash_time = benchmark_timer_read(); |
---|
[8f71a36] | 289 | |
---|
[dbf4f17] | 290 | benchmark_timer_initialize(); |
---|
[cdf30f05] | 291 | rtems_interrupt_local_enable( level ); |
---|
[dbf4f17] | 292 | isr_enable_time = benchmark_timer_read(); |
---|
[8f71a36] | 293 | |
---|
[dab902d5] | 294 | _Thread_Dispatch_enable( _Per_CPU_Get() ); |
---|
[bf30999] | 295 | |
---|
[dbf4f17] | 296 | benchmark_timer_initialize(); |
---|
[dab902d5] | 297 | _Thread_Dispatch_disable(); |
---|
[dbf4f17] | 298 | thread_disable_dispatch_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 299 | |
---|
[dbf4f17] | 300 | benchmark_timer_initialize(); |
---|
[dab902d5] | 301 | _Thread_Dispatch_enable( _Per_CPU_Get() ); |
---|
[dbf4f17] | 302 | thread_enable_dispatch_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 303 | |
---|
[dbf4f17] | 304 | benchmark_timer_initialize(); |
---|
[dab902d5] | 305 | _Thread_Set_state( _Thread_Get_executing(), STATES_SUSPENDED ); |
---|
[dbf4f17] | 306 | thread_set_state_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 307 | |
---|
[e31a9c8] | 308 | set_thread_dispatch_necessary( true ); |
---|
[ac7d5ef0] | 309 | |
---|
[dbf4f17] | 310 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 311 | _Thread_Dispatch(); /* dispatches Middle_task */ |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | rtems_task Middle_task( |
---|
| 315 | rtems_task_argument argument |
---|
| 316 | ) |
---|
| 317 | { |
---|
[e1598a6] | 318 | Scheduler_priority_Context *scheduler_context = |
---|
| 319 | _Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) ); |
---|
[df0f27f] | 320 | |
---|
[dbf4f17] | 321 | thread_dispatch_no_fp_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 322 | |
---|
[dab902d5] | 323 | _Thread_Set_state( _Thread_Get_executing(), STATES_SUSPENDED ); |
---|
[ac7d5ef0] | 324 | |
---|
[e31a9c8] | 325 | Middle_tcb = _Thread_Get_executing(); |
---|
[ac7d5ef0] | 326 | |
---|
[e31a9c8] | 327 | set_thread_executing( |
---|
[e1598a6] | 328 | (Thread_Control *) _Chain_First(&scheduler_context->Ready[LOW_PRIORITY]) |
---|
[e31a9c8] | 329 | ); |
---|
[ac7d5ef0] | 330 | |
---|
| 331 | /* do not force context switch */ |
---|
| 332 | |
---|
[e31a9c8] | 333 | set_thread_dispatch_necessary( false ); |
---|
[ac7d5ef0] | 334 | |
---|
[dab902d5] | 335 | _Thread_Dispatch_disable(); |
---|
[459f770] | 336 | |
---|
[dbf4f17] | 337 | benchmark_timer_initialize(); |
---|
[e31a9c8] | 338 | _Context_Switch( |
---|
| 339 | &Middle_tcb->Registers, |
---|
| 340 | &_Thread_Get_executing()->Registers |
---|
| 341 | ); |
---|
[7950309] | 342 | |
---|
[dbf4f17] | 343 | benchmark_timer_initialize(); |
---|
[7950309] | 344 | _Context_Switch(&Middle_tcb->Registers, &Low_tcb->Registers); |
---|
[ac7d5ef0] | 345 | } |
---|
| 346 | |
---|
| 347 | rtems_task Low_task( |
---|
| 348 | rtems_task_argument argument |
---|
| 349 | ) |
---|
| 350 | { |
---|
[e1598a6] | 351 | Scheduler_priority_Context *scheduler_context = |
---|
| 352 | _Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) ); |
---|
[494c2e3] | 353 | Thread_Control *executing; |
---|
[ac7d5ef0] | 354 | |
---|
[dbf4f17] | 355 | context_switch_no_fp_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 356 | |
---|
[e31a9c8] | 357 | executing = _Thread_Get_executing(); |
---|
[ac7d5ef0] | 358 | |
---|
[7950309] | 359 | Low_tcb = executing; |
---|
| 360 | |
---|
[dbf4f17] | 361 | benchmark_timer_initialize(); |
---|
[7950309] | 362 | _Context_Switch( &executing->Registers, &executing->Registers ); |
---|
| 363 | |
---|
[dbf4f17] | 364 | context_switch_self_time = benchmark_timer_read(); |
---|
[7950309] | 365 | |
---|
| 366 | _Context_Switch(&executing->Registers, &Middle_tcb->Registers); |
---|
| 367 | |
---|
[dbf4f17] | 368 | context_switch_another_task_time = benchmark_timer_read(); |
---|
[7950309] | 369 | |
---|
[e31a9c8] | 370 | set_thread_executing( |
---|
[e1598a6] | 371 | (Thread_Control *) _Chain_First(&scheduler_context->Ready[FP1_PRIORITY]) |
---|
[e31a9c8] | 372 | ); |
---|
[ac7d5ef0] | 373 | |
---|
| 374 | /* do not force context switch */ |
---|
| 375 | |
---|
[e31a9c8] | 376 | set_thread_dispatch_necessary( false ); |
---|
[ac7d5ef0] | 377 | |
---|
[dab902d5] | 378 | _Thread_Dispatch_disable(); |
---|
[459f770] | 379 | |
---|
[dbf4f17] | 380 | benchmark_timer_initialize(); |
---|
[e31a9c8] | 381 | _Context_Switch( |
---|
| 382 | &executing->Registers, |
---|
| 383 | &_Thread_Get_executing()->Registers |
---|
| 384 | ); |
---|
[ac7d5ef0] | 385 | } |
---|
| 386 | |
---|
| 387 | rtems_task Floating_point_task_1( |
---|
| 388 | rtems_task_argument argument |
---|
| 389 | ) |
---|
| 390 | { |
---|
[e1598a6] | 391 | Scheduler_priority_Context *scheduler_context = |
---|
| 392 | _Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) ); |
---|
[494c2e3] | 393 | Thread_Control *executing; |
---|
[ac7d5ef0] | 394 | FP_DECLARE; |
---|
| 395 | |
---|
[dbf4f17] | 396 | context_switch_restore_1st_fp_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 397 | |
---|
[e31a9c8] | 398 | executing = _Thread_Get_executing(); |
---|
[ac7d5ef0] | 399 | |
---|
[e31a9c8] | 400 | set_thread_executing( |
---|
[e1598a6] | 401 | (Thread_Control *) _Chain_First(&scheduler_context->Ready[FP2_PRIORITY]) |
---|
[e31a9c8] | 402 | ); |
---|
[ac7d5ef0] | 403 | |
---|
| 404 | /* do not force context switch */ |
---|
| 405 | |
---|
[e31a9c8] | 406 | set_thread_dispatch_necessary( false ); |
---|
[ac7d5ef0] | 407 | |
---|
[dab902d5] | 408 | _Thread_Dispatch_disable(); |
---|
[459f770] | 409 | |
---|
[dbf4f17] | 410 | benchmark_timer_initialize(); |
---|
[ca7858bb] | 411 | #if (CPU_HARDWARE_FP == 1) || (CPU_SOFTWARE_FP == 1) |
---|
[ac7d5ef0] | 412 | _Context_Save_fp( &executing->fp_context ); |
---|
[e31a9c8] | 413 | _Context_Restore_fp( &_Thread_Get_executing()->fp_context ); |
---|
[ca7858bb] | 414 | #endif |
---|
[e31a9c8] | 415 | _Context_Switch( |
---|
| 416 | &executing->Registers, |
---|
| 417 | &_Thread_Get_executing()->Registers |
---|
| 418 | ); |
---|
[ac7d5ef0] | 419 | /* switch to Floating_point_task_2 */ |
---|
| 420 | |
---|
[dbf4f17] | 421 | context_switch_save_idle_restore_initted_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 422 | |
---|
| 423 | FP_LOAD( 1.0 ); |
---|
| 424 | |
---|
[e31a9c8] | 425 | executing = _Thread_Get_executing(); |
---|
[ac7d5ef0] | 426 | |
---|
[e31a9c8] | 427 | set_thread_executing( |
---|
[e1598a6] | 428 | (Thread_Control *) _Chain_First(&scheduler_context->Ready[FP2_PRIORITY]) |
---|
[e31a9c8] | 429 | ); |
---|
[ac7d5ef0] | 430 | |
---|
[dbf4f17] | 431 | benchmark_timer_initialize(); |
---|
[ca7858bb] | 432 | #if (CPU_HARDWARE_FP == 1) || (CPU_SOFTWARE_FP == 1) |
---|
[ac7d5ef0] | 433 | _Context_Save_fp( &executing->fp_context ); |
---|
[e31a9c8] | 434 | _Context_Restore_fp( &_Thread_Get_executing()->fp_context ); |
---|
[ca7858bb] | 435 | #endif |
---|
[e31a9c8] | 436 | _Context_Switch( |
---|
| 437 | &executing->Registers, |
---|
| 438 | &_Thread_Get_executing()->Registers |
---|
| 439 | ); |
---|
[ac7d5ef0] | 440 | /* switch to Floating_point_task_2 */ |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | rtems_task Floating_point_task_2( |
---|
| 444 | rtems_task_argument argument |
---|
| 445 | ) |
---|
| 446 | { |
---|
[e1598a6] | 447 | Scheduler_priority_Context *scheduler_context = |
---|
| 448 | _Scheduler_priority_Get_context( _Scheduler_Get( _Thread_Get_executing() ) ); |
---|
[494c2e3] | 449 | Thread_Control *executing; |
---|
[ac7d5ef0] | 450 | FP_DECLARE; |
---|
| 451 | |
---|
[dbf4f17] | 452 | context_switch_save_restore_idle_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 453 | |
---|
[e31a9c8] | 454 | executing = _Thread_Get_executing(); |
---|
[ac7d5ef0] | 455 | |
---|
[e31a9c8] | 456 | set_thread_executing( |
---|
[e1598a6] | 457 | (Thread_Control *) _Chain_First(&scheduler_context->Ready[FP1_PRIORITY]) |
---|
[e31a9c8] | 458 | ); |
---|
[ac7d5ef0] | 459 | |
---|
| 460 | FP_LOAD( 1.0 ); |
---|
| 461 | |
---|
[dbf4f17] | 462 | benchmark_timer_initialize(); |
---|
[ca7858bb] | 463 | #if (CPU_HARDWARE_FP == 1) || (CPU_SOFTWARE_FP == 1) |
---|
[ac7d5ef0] | 464 | _Context_Save_fp( &executing->fp_context ); |
---|
[e31a9c8] | 465 | _Context_Restore_fp( &_Thread_Get_executing()->fp_context ); |
---|
[ca7858bb] | 466 | #endif |
---|
[e31a9c8] | 467 | _Context_Switch( |
---|
| 468 | &executing->Registers, |
---|
| 469 | &_Thread_Get_executing()->Registers |
---|
| 470 | ); |
---|
[ac7d5ef0] | 471 | /* switch to Floating_point_task_1 */ |
---|
| 472 | |
---|
[dbf4f17] | 473 | context_switch_save_restore_initted_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 474 | |
---|
| 475 | complete_test(); |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | void complete_test( void ) |
---|
| 479 | { |
---|
[631b3c8] | 480 | uint32_t index; |
---|
| 481 | rtems_id task_id; |
---|
| 482 | ISR_lock_Context lock_context; |
---|
| 483 | Thread_queue_Context queue_context; |
---|
[ac7d5ef0] | 484 | |
---|
[dbf4f17] | 485 | benchmark_timer_initialize(); |
---|
[bf30999] | 486 | thread_resume( Middle_tcb ); |
---|
[dbf4f17] | 487 | thread_resume_time = benchmark_timer_read(); |
---|
[2617b345] | 488 | |
---|
[dab902d5] | 489 | _Thread_Set_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE ); |
---|
[2617b345] | 490 | |
---|
[dbf4f17] | 491 | benchmark_timer_initialize(); |
---|
[dab902d5] | 492 | _Thread_Unblock( Middle_tcb ); |
---|
[dbf4f17] | 493 | thread_unblock_time = benchmark_timer_read(); |
---|
[2617b345] | 494 | |
---|
[dab902d5] | 495 | _Thread_Set_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE ); |
---|
[2617b345] | 496 | |
---|
[dbf4f17] | 497 | benchmark_timer_initialize(); |
---|
[dab902d5] | 498 | _Thread_Clear_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE ); |
---|
[dbf4f17] | 499 | thread_ready_time = benchmark_timer_read(); |
---|
[2617b345] | 500 | |
---|
[dbf4f17] | 501 | benchmark_timer_initialize(); |
---|
[2617b345] | 502 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[dbf4f17] | 503 | (void) benchmark_timer_empty_function(); |
---|
| 504 | overhead = benchmark_timer_read(); |
---|
[2617b345] | 505 | |
---|
| 506 | task_id = Middle_tcb->Object.id; |
---|
| 507 | |
---|
[dbf4f17] | 508 | benchmark_timer_initialize(); |
---|
[5eac9676] | 509 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
[e266d13] | 510 | (void) _Thread_Get( task_id, &lock_context ); |
---|
[5eac9676] | 511 | _ISR_lock_ISR_enable( &lock_context ); |
---|
| 512 | } |
---|
[dbf4f17] | 513 | thread_get_time = benchmark_timer_read(); |
---|
[2617b345] | 514 | |
---|
[dbf4f17] | 515 | benchmark_timer_initialize(); |
---|
[f009ed0] | 516 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
[0e1d11f3] | 517 | (void) _Semaphore_Get( Semaphore_id, &queue_context ); |
---|
[e41308ea] | 518 | _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context ); |
---|
[f009ed0] | 519 | } |
---|
[dbf4f17] | 520 | semaphore_get_time = benchmark_timer_read(); |
---|
[2617b345] | 521 | |
---|
[dbf4f17] | 522 | benchmark_timer_initialize(); |
---|
[5eac9676] | 523 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
[e266d13] | 524 | (void) _Thread_Get( 0x3, &lock_context ); |
---|
[5eac9676] | 525 | _ISR_lock_ISR_enable( &lock_context ); |
---|
| 526 | } |
---|
[dbf4f17] | 527 | thread_get_invalid_time = benchmark_timer_read(); |
---|
[2617b345] | 528 | |
---|
[54a43fe4] | 529 | /* |
---|
| 530 | * This is the running task and we have tricked RTEMS out enough where |
---|
| 531 | * we need to set some internal tracking information to match this. |
---|
| 532 | */ |
---|
| 533 | |
---|
[e31a9c8] | 534 | set_thread_heir( _Thread_Get_executing() ); |
---|
| 535 | set_thread_dispatch_necessary( false ); |
---|
| 536 | |
---|
[2617b345] | 537 | /* |
---|
| 538 | * Now dump all the times |
---|
| 539 | */ |
---|
[ac7d5ef0] | 540 | |
---|
| 541 | put_time( |
---|
[24713163] | 542 | "rtems interrupt: _ISR_Local_disable", |
---|
[2617b345] | 543 | isr_disable_time, |
---|
[ac7d5ef0] | 544 | 1, |
---|
| 545 | 0, |
---|
| 546 | 0 |
---|
| 547 | ); |
---|
| 548 | |
---|
[2617b345] | 549 | put_time( |
---|
[c2f301b5] | 550 | "rtems interrupt: _ISR_Local_flash", |
---|
[2617b345] | 551 | isr_flash_time, |
---|
| 552 | 1, |
---|
| 553 | 0, |
---|
| 554 | 0 |
---|
| 555 | ); |
---|
[8f71a36] | 556 | |
---|
[2617b345] | 557 | put_time( |
---|
[24713163] | 558 | "rtems interrupt: _ISR_Local_enable", |
---|
[2617b345] | 559 | isr_enable_time, |
---|
| 560 | 1, |
---|
| 561 | 0, |
---|
| 562 | 0 |
---|
| 563 | ); |
---|
[8f71a36] | 564 | |
---|
[2617b345] | 565 | put_time( |
---|
[dab902d5] | 566 | "rtems internal: _Thread_Dispatch_disable", |
---|
[2617b345] | 567 | thread_disable_dispatch_time, |
---|
| 568 | 1, |
---|
| 569 | 0, |
---|
| 570 | 0 |
---|
| 571 | ); |
---|
[ac7d5ef0] | 572 | |
---|
[2617b345] | 573 | put_time( |
---|
[dab902d5] | 574 | "rtems internal: _Thread_Dispatch_enable", |
---|
[2617b345] | 575 | thread_enable_dispatch_time, |
---|
| 576 | 1, |
---|
| 577 | 0, |
---|
| 578 | 0 |
---|
| 579 | ); |
---|
[ac7d5ef0] | 580 | |
---|
| 581 | put_time( |
---|
[9410d011] | 582 | "rtems internal: _Thread_Set_state", |
---|
[2617b345] | 583 | thread_set_state_time, |
---|
[ac7d5ef0] | 584 | 1, |
---|
| 585 | 0, |
---|
| 586 | 0 |
---|
| 587 | ); |
---|
| 588 | |
---|
[2617b345] | 589 | put_time( |
---|
[9410d011] | 590 | "rtems internal: _Thread_Dispatch NO FP", |
---|
[2617b345] | 591 | thread_dispatch_no_fp_time, |
---|
| 592 | 1, |
---|
| 593 | 0, |
---|
| 594 | 0 |
---|
| 595 | ); |
---|
[ac7d5ef0] | 596 | |
---|
[2617b345] | 597 | put_time( |
---|
[9410d011] | 598 | "rtems internal: context switch: no floating point contexts", |
---|
[2617b345] | 599 | context_switch_no_fp_time, |
---|
| 600 | 1, |
---|
| 601 | 0, |
---|
| 602 | 0 |
---|
| 603 | ); |
---|
[ac7d5ef0] | 604 | |
---|
| 605 | put_time( |
---|
[9410d011] | 606 | "rtems internal: context switch: self", |
---|
[2617b345] | 607 | context_switch_self_time, |
---|
[ac7d5ef0] | 608 | 1, |
---|
| 609 | 0, |
---|
| 610 | 0 |
---|
| 611 | ); |
---|
| 612 | |
---|
[2617b345] | 613 | put_time( |
---|
[9410d011] | 614 | "rtems internal: context switch to another task", |
---|
[2617b345] | 615 | context_switch_another_task_time, |
---|
| 616 | 1, |
---|
| 617 | 0, |
---|
| 618 | 0 |
---|
| 619 | ); |
---|
[ac7d5ef0] | 620 | |
---|
[ca7858bb] | 621 | #if (CPU_HARDWARE_FP == 1) || (CPU_SOFTWARE_FP == 1) |
---|
[2617b345] | 622 | put_time( |
---|
[9410d011] | 623 | "rtems internal: fp context switch restore 1st FP task", |
---|
[2617b345] | 624 | context_switch_restore_1st_fp_time, |
---|
| 625 | 1, |
---|
| 626 | 0, |
---|
| 627 | 0 |
---|
| 628 | ); |
---|
[ac7d5ef0] | 629 | |
---|
[2617b345] | 630 | put_time( |
---|
[9410d011] | 631 | "rtems internal: fp context switch save idle and restore initialized", |
---|
[2617b345] | 632 | context_switch_save_idle_restore_initted_time, |
---|
| 633 | 1, |
---|
| 634 | 0, |
---|
| 635 | 0 |
---|
| 636 | ); |
---|
| 637 | |
---|
| 638 | put_time( |
---|
[9410d011] | 639 | "rtems internal: fp context switch save idle, restore idle", |
---|
[2617b345] | 640 | context_switch_save_restore_idle_time, |
---|
| 641 | 1, |
---|
| 642 | 0, |
---|
| 643 | 0 |
---|
| 644 | ); |
---|
| 645 | |
---|
| 646 | put_time( |
---|
[9410d011] | 647 | "rtems internal: fp context switch save initialized, restore initialized", |
---|
[2617b345] | 648 | context_switch_save_restore_initted_time, |
---|
| 649 | 1, |
---|
| 650 | 0, |
---|
| 651 | 0 |
---|
| 652 | ); |
---|
[ca7858bb] | 653 | #else |
---|
[9410d011] | 654 | puts( |
---|
| 655 | "rtems internal: fp context switch restore 1st FP task - NA\n" |
---|
| 656 | "rtems internal: fp context switch save idle restore initialized - NA\n" |
---|
| 657 | "rtems internal: fp context switch save idle restore idle - NA\n" |
---|
| 658 | "rtems internal: fp context switch save initialized\n" |
---|
| 659 | " restore initialized - NA" |
---|
| 660 | ); |
---|
[ca7858bb] | 661 | #endif |
---|
[2617b345] | 662 | |
---|
| 663 | put_time( |
---|
[9410d011] | 664 | "rtems internal: _Thread_Resume", |
---|
[2617b345] | 665 | thread_resume_time, |
---|
| 666 | 1, |
---|
| 667 | 0, |
---|
| 668 | 0 |
---|
| 669 | ); |
---|
| 670 | |
---|
| 671 | put_time( |
---|
[9410d011] | 672 | "rtems internal: _Thread_Unblock", |
---|
[2617b345] | 673 | thread_unblock_time, |
---|
| 674 | 1, |
---|
| 675 | 0, |
---|
| 676 | 0 |
---|
| 677 | ); |
---|
| 678 | |
---|
| 679 | put_time( |
---|
[9410d011] | 680 | "rtems internal: _Thread_Ready", |
---|
[2617b345] | 681 | thread_ready_time, |
---|
| 682 | 1, |
---|
| 683 | 0, |
---|
| 684 | 0 |
---|
| 685 | ); |
---|
[ac7d5ef0] | 686 | |
---|
| 687 | put_time( |
---|
[e266d13] | 688 | "rtems internal: _Thread_Get", |
---|
[2617b345] | 689 | thread_get_time, |
---|
[ac7d5ef0] | 690 | OPERATION_COUNT, |
---|
| 691 | 0, |
---|
| 692 | 0 |
---|
| 693 | ); |
---|
| 694 | |
---|
| 695 | put_time( |
---|
[e266d13] | 696 | "rtems internal: _Semaphore_Get", |
---|
[2617b345] | 697 | semaphore_get_time, |
---|
[ac7d5ef0] | 698 | OPERATION_COUNT, |
---|
| 699 | 0, |
---|
| 700 | 0 |
---|
| 701 | ); |
---|
| 702 | |
---|
| 703 | put_time( |
---|
[e266d13] | 704 | "rtems internal: _Thread_Get: invalid id", |
---|
[2617b345] | 705 | thread_get_invalid_time, |
---|
[ac7d5ef0] | 706 | OPERATION_COUNT, |
---|
| 707 | 0, |
---|
| 708 | 0 |
---|
| 709 | ); |
---|
[3a4ae6c] | 710 | |
---|
[2ead50a] | 711 | TEST_END(); |
---|
[b454bc9] | 712 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 713 | } |
---|