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