[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 | * |
---|
[03f2154e] | 11 | * COPYRIGHT (c) 1989-1997. |
---|
[61a183a9] | 12 | * On-Line Applications Research Corporation (OAR). |
---|
[03f2154e] | 13 | * Copyright assigned to U.S. Government, 1994. |
---|
[61a183a9] | 14 | * |
---|
[03f2154e] | 15 | * The license and distribution terms for this file may in |
---|
| 16 | * the file LICENSE in this distribution or at |
---|
| 17 | * http://www.OARcorp.com/rtems/license.html. |
---|
[61a183a9] | 18 | * |
---|
| 19 | * task1.c,v 1.3 1995/12/19 20:21:14 joel Exp |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #include "system.h" |
---|
| 23 | |
---|
| 24 | #include <cpuuse.h> |
---|
| 25 | #include "rtmonuse.h" |
---|
| 26 | |
---|
| 27 | rtems_unsigned32 Periods[6] = { 0, 2, 2, 2, 2, 100 }; |
---|
| 28 | rtems_unsigned32 Iterations[6] = { 0, 50, 50, 50, 50, 1 }; |
---|
| 29 | rtems_task_priority Priorities[6] = { 0, 1, 1, 3, 4, 5 }; |
---|
| 30 | |
---|
| 31 | rtems_task Task_1_through_5( |
---|
| 32 | rtems_unsigned32 argument |
---|
| 33 | ) |
---|
| 34 | { |
---|
| 35 | rtems_id rmid; |
---|
| 36 | rtems_id test_rmid; |
---|
| 37 | rtems_unsigned32 index; |
---|
| 38 | rtems_unsigned32 pass; |
---|
| 39 | rtems_unsigned32 failed; |
---|
| 40 | rtems_status_code status; |
---|
| 41 | |
---|
| 42 | status = rtems_rate_monotonic_create( argument, &rmid ); |
---|
| 43 | directive_failed( status, "rtems_rate_monotonic_create" ); |
---|
| 44 | put_name( Task_name[ argument ], FALSE ); |
---|
| 45 | printf( "- rtems_rate_monotonic_create id = 0x%08x\n", rmid ); |
---|
| 46 | |
---|
| 47 | status = rtems_rate_monotonic_ident( argument, &test_rmid ); |
---|
| 48 | directive_failed( status, "rtems_rate_monotonic_ident" ); |
---|
| 49 | put_name( Task_name[ argument ], FALSE ); |
---|
| 50 | printf( "- rtems_rate_monotonic_ident id = 0x%08x\n", test_rmid ); |
---|
| 51 | |
---|
| 52 | if ( rmid != test_rmid ) { |
---|
| 53 | printf( "RMID's DO NOT MATCH (0x%x and 0x%x)\n", rmid, test_rmid ); |
---|
| 54 | exit( 0 ); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | put_name( Task_name[ argument ], FALSE ); |
---|
| 58 | printf( "- (0x%08x) period %d\n", rmid, Periods[ argument ] ); |
---|
| 59 | |
---|
| 60 | status = rtems_task_wake_after( 2 ); |
---|
| 61 | directive_failed( status, "rtems_task_wake_after" ); |
---|
| 62 | |
---|
| 63 | switch ( argument ) { |
---|
| 64 | case 1: |
---|
| 65 | case 2: |
---|
| 66 | case 3: |
---|
| 67 | case 4: |
---|
| 68 | while ( FOREVER ) { |
---|
| 69 | Period_usage_Update( rmid ); |
---|
| 70 | |
---|
| 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 | Period_usage_Update( rmid ); |
---|
| 87 | |
---|
| 88 | status = rtems_rate_monotonic_period( rmid, Periods[ argument ] ); |
---|
| 89 | directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" ); |
---|
| 90 | |
---|
| 91 | Get_all_counters(); |
---|
| 92 | |
---|
| 93 | for( index = 1 ; index <= 4 ; index++ ) { |
---|
| 94 | if ( Temporary_count.count[ index ] != Iterations[ index ] ) { |
---|
| 95 | puts_nocr( "FAIL -- " ); |
---|
| 96 | put_name ( Task_name[ index ], FALSE ); |
---|
| 97 | printf ( " Actual=%d, Expected=%d\n", |
---|
| 98 | Temporary_count.count[ index ], |
---|
| 99 | Iterations[ index ] |
---|
| 100 | ); |
---|
| 101 | failed += 1; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | if ( failed == 5 ) |
---|
| 106 | exit( 0 ); |
---|
| 107 | |
---|
| 108 | pass += 1; |
---|
| 109 | |
---|
| 110 | printf( "TA5 - PERIODS CHECK OK (%d)\n", pass ); |
---|
| 111 | |
---|
| 112 | fflush( stdout ); |
---|
| 113 | |
---|
| 114 | if ( pass == 10 ) { |
---|
| 115 | puts( "*** END OF RATE MONOTONIC PERIOD STATISTICS TEST ***" ); |
---|
| 116 | CPU_usage_Dump(); |
---|
| 117 | Period_usage_Dump(); |
---|
| 118 | exit( 0 ); |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | } |
---|
| 122 | break; |
---|
| 123 | } |
---|
| 124 | } |
---|