[61a183a9] | 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 | * |
---|
[81ee994] | 11 | * COPYRIGHT (c) 1989-2007. |
---|
[61a183a9] | 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 |
---|
[2abdd87] | 16 | * http://www.rtems.com/license/LICENSE. |
---|
[61a183a9] | 17 | * |
---|
[6f9c75c3] | 18 | * $Id$ |
---|
[61a183a9] | 19 | */ |
---|
| 20 | |
---|
| 21 | #include "system.h" |
---|
| 22 | |
---|
[bfc3533] | 23 | #include <rtems/cpuuse.h> |
---|
[61a183a9] | 24 | |
---|
[9919946a] | 25 | uint32_t Periods[6] = { 0, 2, 2, 2, 2, 100 }; |
---|
| 26 | uint32_t Iterations[6] = { 0, 50, 50, 50, 50, 1 }; |
---|
[61a183a9] | 27 | rtems_task_priority Priorities[6] = { 0, 1, 1, 3, 4, 5 }; |
---|
| 28 | |
---|
| 29 | rtems_task Task_1_through_5( |
---|
[9072167] | 30 | rtems_task_argument argument |
---|
[61a183a9] | 31 | ) |
---|
| 32 | { |
---|
| 33 | rtems_id rmid; |
---|
| 34 | rtems_id test_rmid; |
---|
[9919946a] | 35 | uint32_t index; |
---|
| 36 | uint32_t pass; |
---|
| 37 | uint32_t failed; |
---|
[61a183a9] | 38 | rtems_status_code status; |
---|
| 39 | |
---|
| 40 | status = rtems_rate_monotonic_create( argument, &rmid ); |
---|
| 41 | directive_failed( status, "rtems_rate_monotonic_create" ); |
---|
| 42 | put_name( Task_name[ argument ], FALSE ); |
---|
| 43 | printf( "- rtems_rate_monotonic_create id = 0x%08x\n", rmid ); |
---|
| 44 | |
---|
| 45 | status = rtems_rate_monotonic_ident( argument, &test_rmid ); |
---|
| 46 | directive_failed( status, "rtems_rate_monotonic_ident" ); |
---|
| 47 | put_name( Task_name[ argument ], FALSE ); |
---|
| 48 | printf( "- rtems_rate_monotonic_ident id = 0x%08x\n", test_rmid ); |
---|
| 49 | |
---|
| 50 | if ( rmid != test_rmid ) { |
---|
| 51 | printf( "RMID's DO NOT MATCH (0x%x and 0x%x)\n", rmid, test_rmid ); |
---|
[016a926] | 52 | rtems_test_exit( 0 ); |
---|
[61a183a9] | 53 | } |
---|
| 54 | |
---|
| 55 | put_name( Task_name[ argument ], FALSE ); |
---|
| 56 | printf( "- (0x%08x) period %d\n", rmid, Periods[ argument ] ); |
---|
| 57 | |
---|
| 58 | status = rtems_task_wake_after( 2 ); |
---|
| 59 | directive_failed( status, "rtems_task_wake_after" ); |
---|
| 60 | |
---|
| 61 | switch ( argument ) { |
---|
| 62 | case 1: |
---|
| 63 | case 2: |
---|
| 64 | case 3: |
---|
| 65 | case 4: |
---|
| 66 | while ( FOREVER ) { |
---|
| 67 | status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); |
---|
| 68 | directive_failed( status, "rtems_rate_monotonic_period" ); |
---|
| 69 | Count.count[ argument ]++; |
---|
| 70 | } |
---|
| 71 | break; |
---|
| 72 | case 5: |
---|
| 73 | pass = 0; |
---|
| 74 | failed = 0; |
---|
| 75 | |
---|
| 76 | status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); |
---|
| 77 | directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" ); |
---|
| 78 | |
---|
| 79 | Get_all_counters(); |
---|
| 80 | |
---|
| 81 | while ( FOREVER ) { |
---|
| 82 | status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); |
---|
| 83 | directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" ); |
---|
| 84 | |
---|
| 85 | Get_all_counters(); |
---|
| 86 | |
---|
| 87 | for( index = 1 ; index <= 4 ; index++ ) { |
---|
| 88 | if ( Temporary_count.count[ index ] != Iterations[ index ] ) { |
---|
| 89 | puts_nocr( "FAIL -- " ); |
---|
| 90 | put_name ( Task_name[ index ], FALSE ); |
---|
| 91 | printf ( " Actual=%d, Expected=%d\n", |
---|
| 92 | Temporary_count.count[ index ], |
---|
| 93 | Iterations[ index ] |
---|
| 94 | ); |
---|
| 95 | failed += 1; |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | if ( failed == 5 ) |
---|
[016a926] | 100 | rtems_test_exit( 0 ); |
---|
[61a183a9] | 101 | |
---|
| 102 | pass += 1; |
---|
| 103 | |
---|
| 104 | printf( "TA5 - PERIODS CHECK OK (%d)\n", pass ); |
---|
| 105 | |
---|
[838167e] | 106 | FLUSH_OUTPUT(); |
---|
[61a183a9] | 107 | |
---|
| 108 | if ( pass == 10 ) { |
---|
[838167e] | 109 | puts( "" ); |
---|
[43e3429] | 110 | rtems_rate_monotonic_report_statistics(); |
---|
| 111 | |
---|
| 112 | rtems_rate_monotonic_reset_statistics( rmid ); |
---|
| 113 | puts( "" ); |
---|
| 114 | puts( "TA5 - PERIOD STATISTICS RESET" ); |
---|
| 115 | puts( "" ); |
---|
| 116 | rtems_rate_monotonic_report_statistics(); |
---|
| 117 | |
---|
| 118 | rtems_rate_monotonic_reset_all_statistics(); |
---|
| 119 | puts( "" ); |
---|
| 120 | puts( "TA5 - ALL PERIOD STATISTICS RESET" ); |
---|
[838167e] | 121 | puts( "" ); |
---|
| 122 | rtems_rate_monotonic_report_statistics(); |
---|
[43e3429] | 123 | |
---|
[838167e] | 124 | puts( "" ); |
---|
[43e3429] | 125 | puts( "*** END OF RATE MONOTONIC PERIOD STATISTICS TEST ***" ); |
---|
[81ee994] | 126 | |
---|
[016a926] | 127 | rtems_test_exit( 0 ); |
---|
[61a183a9] | 128 | } |
---|
| 129 | |
---|
| 130 | } |
---|
| 131 | break; |
---|
| 132 | } |
---|
| 133 | } |
---|