1 | /* |
---|
2 | * |
---|
3 | * COPYRIGHT (c) 1989-1999. |
---|
4 | * On-Line Applications Research Corporation (OAR). |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * http://www.OARcorp.com/rtems/license.html. |
---|
9 | * |
---|
10 | * $Id$ |
---|
11 | */ |
---|
12 | |
---|
13 | /* |
---|
14 | * WARNING!!!!!!!!! |
---|
15 | * |
---|
16 | * THIS TEST USES INTERNAL RTEMS VARIABLES!!! |
---|
17 | */ |
---|
18 | |
---|
19 | #define TEST_INIT |
---|
20 | #define RTEMS_TM27 |
---|
21 | #include "system.h" |
---|
22 | |
---|
23 | #include <bsp.h> |
---|
24 | |
---|
25 | rtems_task Task_1( |
---|
26 | rtems_task_argument argument |
---|
27 | ); |
---|
28 | |
---|
29 | rtems_task Task_2( |
---|
30 | rtems_task_argument argument |
---|
31 | ); |
---|
32 | |
---|
33 | volatile rtems_unsigned32 Interrupt_occurred; |
---|
34 | volatile rtems_unsigned32 Interrupt_enter_time, Interrupt_enter_nested_time; |
---|
35 | volatile rtems_unsigned32 Interrupt_return_time, Interrupt_return_nested_time; |
---|
36 | rtems_unsigned32 Interrupt_nest; |
---|
37 | |
---|
38 | rtems_isr Isr_handler( |
---|
39 | rtems_vector_number vector |
---|
40 | ); |
---|
41 | |
---|
42 | rtems_task Init( |
---|
43 | rtems_task_argument argument |
---|
44 | ) |
---|
45 | { |
---|
46 | rtems_status_code status; |
---|
47 | |
---|
48 | Print_Warning(); |
---|
49 | |
---|
50 | puts( "\n\n*** TIME TEST 27 ***" ); |
---|
51 | |
---|
52 | status = rtems_task_create( |
---|
53 | rtems_build_name( 'T', 'A', '1', ' ' ), |
---|
54 | 254, |
---|
55 | RTEMS_MINIMUM_STACK_SIZE, |
---|
56 | RTEMS_DEFAULT_MODES, |
---|
57 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
58 | &Task_id[ 1 ] |
---|
59 | ); |
---|
60 | directive_failed( status, "rtems_task_create Task_1" ); |
---|
61 | |
---|
62 | status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); |
---|
63 | directive_failed( status, "rtems_task_start Task_1" ); |
---|
64 | |
---|
65 | status = rtems_task_create( |
---|
66 | rtems_build_name( 'T', 'A', '2', ' ' ), |
---|
67 | 254, |
---|
68 | RTEMS_MINIMUM_STACK_SIZE, |
---|
69 | RTEMS_DEFAULT_MODES, |
---|
70 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
71 | &Task_id[ 2 ] |
---|
72 | ); |
---|
73 | directive_failed( status, "rtems_task_create of Task_2" ); |
---|
74 | |
---|
75 | status = rtems_task_start( Task_id[ 2 ], Task_2, 0 ); |
---|
76 | directive_failed( status, "rtems_task_start of Task_2" ); |
---|
77 | |
---|
78 | status = rtems_task_delete( RTEMS_SELF ); |
---|
79 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
80 | } |
---|
81 | |
---|
82 | rtems_task Task_1( |
---|
83 | rtems_task_argument argument |
---|
84 | ) |
---|
85 | { |
---|
86 | Install_tm27_vector( Isr_handler ); |
---|
87 | |
---|
88 | /* |
---|
89 | * No preempt .. no nesting |
---|
90 | */ |
---|
91 | |
---|
92 | Interrupt_nest = 0; |
---|
93 | |
---|
94 | _Thread_Dispatch_disable_level = 0; |
---|
95 | |
---|
96 | Interrupt_occurred = 0; |
---|
97 | Timer_initialize(); |
---|
98 | Cause_tm27_intr(); |
---|
99 | /* goes to Isr_handler */ |
---|
100 | |
---|
101 | #if (MUST_WAIT_FOR_INTERRUPT == 1) |
---|
102 | while ( Interrupt_occurred == 0 ); |
---|
103 | #endif |
---|
104 | Interrupt_return_time = Read_timer(); |
---|
105 | |
---|
106 | put_time( |
---|
107 | "interrupt entry overhead: returns to interrupted task", |
---|
108 | Interrupt_enter_time, |
---|
109 | 1, |
---|
110 | 0, |
---|
111 | 0 |
---|
112 | ); |
---|
113 | |
---|
114 | put_time( |
---|
115 | "interrupt exit overhead: returns to interrupted task", |
---|
116 | Interrupt_return_time, |
---|
117 | 1, |
---|
118 | 0, |
---|
119 | 0 |
---|
120 | ); |
---|
121 | |
---|
122 | /* |
---|
123 | * No preempt .. nested |
---|
124 | */ |
---|
125 | |
---|
126 | _Thread_Dispatch_disable_level = 1; |
---|
127 | |
---|
128 | Interrupt_nest = 1; |
---|
129 | |
---|
130 | Interrupt_occurred = 0; |
---|
131 | Timer_initialize(); |
---|
132 | Cause_tm27_intr(); |
---|
133 | /* goes to Isr_handler */ |
---|
134 | |
---|
135 | #if (MUST_WAIT_FOR_INTERRUPT == 1) |
---|
136 | while ( Interrupt_occurred == 0 ); |
---|
137 | #endif |
---|
138 | Interrupt_return_time = Read_timer(); |
---|
139 | |
---|
140 | put_time( |
---|
141 | "interrupt entry overhead: returns to nested interrupt", |
---|
142 | Interrupt_enter_nested_time, |
---|
143 | 1, |
---|
144 | 0, |
---|
145 | 0 |
---|
146 | ); |
---|
147 | |
---|
148 | put_time( |
---|
149 | "interrupt exit overhead: returns to nested interrupt", |
---|
150 | Interrupt_return_nested_time, |
---|
151 | 1, |
---|
152 | 0, |
---|
153 | 0 |
---|
154 | ); |
---|
155 | |
---|
156 | /* |
---|
157 | * Does a preempt .. not nested |
---|
158 | */ |
---|
159 | |
---|
160 | _Thread_Dispatch_disable_level = 0; |
---|
161 | |
---|
162 | _Thread_Heir = (rtems_tcb *) _Thread_Ready_chain[254].last; |
---|
163 | |
---|
164 | _Context_Switch_necessary = 1; |
---|
165 | |
---|
166 | Interrupt_occurred = 0; |
---|
167 | Timer_initialize(); |
---|
168 | Cause_tm27_intr(); |
---|
169 | |
---|
170 | /* |
---|
171 | * goes to Isr_handler and then returns |
---|
172 | */ |
---|
173 | |
---|
174 | puts( "*** END OF TEST 27 ***" ); |
---|
175 | exit( 0 ); |
---|
176 | } |
---|
177 | |
---|
178 | /* |
---|
179 | * NOTE: When this task is executing, some of the assumptions made |
---|
180 | * regarding the placement of the currently executing task's TCB |
---|
181 | * on the ready chains have been violated. At least the assumption |
---|
182 | * that this task is at the head of the chain for its priority |
---|
183 | * has been violated. |
---|
184 | */ |
---|
185 | |
---|
186 | rtems_task Task_2( |
---|
187 | rtems_task_argument argument |
---|
188 | ) |
---|
189 | { |
---|
190 | #if (MUST_WAIT_FOR_INTERRUPT == 1) |
---|
191 | while ( Interrupt_occurred == 0 ); |
---|
192 | #endif |
---|
193 | end_time = Read_timer(); |
---|
194 | |
---|
195 | put_time( |
---|
196 | "interrupt entry overhead: returns to preempting task", |
---|
197 | Interrupt_enter_time, |
---|
198 | 1, |
---|
199 | 0, |
---|
200 | 0 |
---|
201 | ); |
---|
202 | |
---|
203 | put_time( |
---|
204 | "interrupt exit overhead: returns to preempting task", |
---|
205 | end_time, |
---|
206 | 1, |
---|
207 | 0, |
---|
208 | 0 |
---|
209 | ); |
---|
210 | |
---|
211 | fflush( stdout ); |
---|
212 | |
---|
213 | /* |
---|
214 | * Switch back to the other task to exit the test. |
---|
215 | */ |
---|
216 | |
---|
217 | _Thread_Dispatch_disable_level = 0; |
---|
218 | |
---|
219 | _Thread_Heir = (rtems_tcb *) _Thread_Ready_chain[254].first; |
---|
220 | |
---|
221 | _Context_Switch_necessary = 1; |
---|
222 | |
---|
223 | _Thread_Dispatch(); |
---|
224 | |
---|
225 | } |
---|
226 | |
---|
227 | /* The Isr_handler() and Isr_handler_inner() routines are structured |
---|
228 | * so that there will be as little entry overhead as possible included |
---|
229 | * in the interrupt entry time. |
---|
230 | */ |
---|
231 | |
---|
232 | void Isr_handler_inner( void ); |
---|
233 | |
---|
234 | rtems_isr Isr_handler( |
---|
235 | rtems_vector_number vector |
---|
236 | ) |
---|
237 | { |
---|
238 | end_time = Read_timer(); |
---|
239 | |
---|
240 | Interrupt_occurred = 1; |
---|
241 | Isr_handler_inner(); |
---|
242 | } |
---|
243 | |
---|
244 | void Isr_handler_inner( void ) |
---|
245 | { |
---|
246 | |
---|
247 | /*enable_tracing();*/ |
---|
248 | Clear_tm27_intr(); |
---|
249 | switch ( Interrupt_nest ) { |
---|
250 | case 0: |
---|
251 | Interrupt_enter_time = end_time; |
---|
252 | break; |
---|
253 | case 1: |
---|
254 | Interrupt_enter_time = end_time; |
---|
255 | Interrupt_nest = 2; |
---|
256 | Interrupt_occurred = 0; |
---|
257 | Lower_tm27_intr(); |
---|
258 | Timer_initialize(); |
---|
259 | Cause_tm27_intr(); |
---|
260 | /* goes to a nested copy of Isr_handler */ |
---|
261 | #if (MUST_WAIT_FOR_INTERRUPT == 1) |
---|
262 | while ( Interrupt_occurred == 0 ); |
---|
263 | #endif |
---|
264 | Interrupt_return_nested_time = Read_timer(); |
---|
265 | break; |
---|
266 | case 2: |
---|
267 | Interrupt_enter_nested_time = end_time; |
---|
268 | break; |
---|
269 | } |
---|
270 | |
---|
271 | Timer_initialize(); |
---|
272 | } |
---|