[ac7d5ef0] | 1 | /* Task_1_through_5 |
---|
| 2 | * |
---|
| 3 | * This routine serves as a test task for the period capabilities of the |
---|
| 4 | * Rate Monotonic Manager. |
---|
| 5 | * |
---|
| 6 | * Input parameters: |
---|
| 7 | * argument - task argument |
---|
| 8 | * |
---|
| 9 | * Output parameters: NONE |
---|
| 10 | * |
---|
[08311cc3] | 11 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 12 | * On-Line Applications Research Corporation (OAR). |
---|
| 13 | * |
---|
[98e4ebf5] | 14 | * The license and distribution terms for this file may be |
---|
| 15 | * found in the file LICENSE in this distribution or at |
---|
[d2b93bfd] | 16 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 17 | * |
---|
| 18 | * $Id$ |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #include "system.h" |
---|
| 22 | |
---|
[cf42c54c] | 23 | /* |
---|
| 24 | runtime of TA6 should be shorter than TA5 |
---|
| 25 | */ |
---|
| 26 | #define TA6_ITERATIONS 10 |
---|
| 27 | #define TA6_PERIOD_FACTOR 10 |
---|
| 28 | |
---|
[c87608f] | 29 | uint32_t Periods[7] = { 0, 2, 2, 2, 2, 100, 0 }; |
---|
| 30 | uint32_t Iterations[7] = { 0, 50, 50, 50, 50, 1, TA6_ITERATIONS }; |
---|
[cf42c54c] | 31 | rtems_task_priority Priorities[7] = { 0, 1, 1, 3, 4, 5, 1 }; |
---|
[ac7d5ef0] | 32 | |
---|
[cf42c54c] | 33 | rtems_task Task_1_through_6( |
---|
[c87608f] | 34 | uint32_t argument |
---|
[ac7d5ef0] | 35 | ) |
---|
| 36 | { |
---|
| 37 | rtems_id rmid; |
---|
| 38 | rtems_id test_rmid; |
---|
[c87608f] | 39 | uint32_t index; |
---|
| 40 | uint32_t pass; |
---|
| 41 | uint32_t failed; |
---|
[ac7d5ef0] | 42 | rtems_status_code status; |
---|
| 43 | |
---|
| 44 | status = rtems_rate_monotonic_create( argument, &rmid ); |
---|
| 45 | directive_failed( status, "rtems_rate_monotonic_create" ); |
---|
| 46 | put_name( Task_name[ argument ], FALSE ); |
---|
| 47 | printf( "- rtems_rate_monotonic_create id = 0x%08x\n", rmid ); |
---|
| 48 | |
---|
| 49 | status = rtems_rate_monotonic_ident( argument, &test_rmid ); |
---|
| 50 | directive_failed( status, "rtems_rate_monotonic_ident" ); |
---|
| 51 | put_name( Task_name[ argument ], FALSE ); |
---|
| 52 | printf( "- rtems_rate_monotonic_ident id = 0x%08x\n", test_rmid ); |
---|
| 53 | |
---|
| 54 | if ( rmid != test_rmid ) { |
---|
| 55 | printf( "RMID's DO NOT MATCH (0x%x and 0x%x)\n", rmid, test_rmid ); |
---|
[3aa4c2e0] | 56 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 57 | } |
---|
| 58 | |
---|
| 59 | put_name( Task_name[ argument ], FALSE ); |
---|
| 60 | printf( "- (0x%08x) period %d\n", rmid, Periods[ argument ] ); |
---|
| 61 | |
---|
| 62 | status = rtems_task_wake_after( 2 ); |
---|
| 63 | directive_failed( status, "rtems_task_wake_after" ); |
---|
| 64 | |
---|
| 65 | switch ( argument ) { |
---|
| 66 | case 1: |
---|
| 67 | case 2: |
---|
| 68 | case 3: |
---|
| 69 | case 4: |
---|
| 70 | while ( FOREVER ) { |
---|
| 71 | status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); |
---|
| 72 | directive_failed( status, "rtems_rate_monotonic_period" ); |
---|
| 73 | Count.count[ argument ]++; |
---|
| 74 | } |
---|
| 75 | break; |
---|
| 76 | case 5: |
---|
| 77 | pass = 0; |
---|
| 78 | failed = 0; |
---|
| 79 | |
---|
| 80 | status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); |
---|
| 81 | directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" ); |
---|
| 82 | |
---|
| 83 | Get_all_counters(); |
---|
| 84 | |
---|
| 85 | while ( FOREVER ) { |
---|
| 86 | |
---|
| 87 | status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); |
---|
| 88 | directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" ); |
---|
| 89 | |
---|
| 90 | Get_all_counters(); |
---|
| 91 | |
---|
| 92 | for( index = 1 ; index <= 4 ; index++ ) { |
---|
| 93 | if ( Temporary_count.count[ index ] != Iterations[ index ] ) { |
---|
| 94 | puts_nocr( "FAIL -- " ); |
---|
| 95 | put_name ( Task_name[ index ], FALSE ); |
---|
| 96 | printf ( " Actual=%d, Expected=%d\n", |
---|
| 97 | Temporary_count.count[ index ], |
---|
| 98 | Iterations[ index ] |
---|
| 99 | ); |
---|
| 100 | failed += 1; |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | if ( failed == 5 ) |
---|
[3aa4c2e0] | 105 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 106 | |
---|
| 107 | pass += 1; |
---|
| 108 | |
---|
| 109 | printf( "TA5 - PERIODS CHECK OK (%d)\n", pass ); |
---|
| 110 | |
---|
| 111 | fflush( stdout ); |
---|
| 112 | |
---|
| 113 | if ( pass == 10 ) { |
---|
| 114 | puts( "*** END OF TEST 20 ***" ); |
---|
[3aa4c2e0] | 115 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 116 | } |
---|
| 117 | |
---|
| 118 | } |
---|
| 119 | break; |
---|
[cf42c54c] | 120 | case 6: |
---|
| 121 | /* test changing periods */ |
---|
| 122 | { |
---|
[c87608f] | 123 | uint32_t time[TA6_ITERATIONS+1]; |
---|
[cf42c54c] | 124 | rtems_interval period; |
---|
| 125 | |
---|
| 126 | period = 1*TA6_PERIOD_FACTOR; |
---|
| 127 | status = rtems_rate_monotonic_period( rmid, period); |
---|
| 128 | directive_failed( status, "rtems_rate_monotonic_period of TA6" ); |
---|
| 129 | time[0] = _Watchdog_Ticks_since_boot; /* timestamp */ |
---|
| 130 | /*printf("%d - %d\n", period, time[0]);*/ |
---|
| 131 | |
---|
| 132 | for (index = 1; index <= TA6_ITERATIONS; index++) |
---|
| 133 | { |
---|
| 134 | period = (index+1)*TA6_PERIOD_FACTOR; |
---|
| 135 | status = rtems_rate_monotonic_period( rmid, period); |
---|
| 136 | directive_failed( status, "rtems_rate_monotonic_period of TA6" ); |
---|
| 137 | time[index] = _Watchdog_Ticks_since_boot; /* timestamp */ |
---|
| 138 | /*printf("%d - %d\n", period, time[index]);*/ |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | for (index = 1; index <= TA6_ITERATIONS; index++) |
---|
| 142 | { |
---|
| 143 | rtems_interval meas = time[index] - time[index-1]; |
---|
| 144 | period = index*TA6_PERIOD_FACTOR; |
---|
| 145 | printf("TA6 - Actual: %d Expected: %d", meas, period); |
---|
| 146 | if (period == meas) printf(" - OK\n"); |
---|
| 147 | else printf(" - FAILED\n"); |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | rtems_task_suspend(RTEMS_SELF); |
---|
| 151 | break; |
---|
[ac7d5ef0] | 152 | } |
---|
| 153 | } |
---|