source: rtems/testsuites/tmtests/tm27/task1.c @ 8f71a36

4.104.114.84.95
Last change on this file since 8f71a36 was 8f71a36, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/20/04 at 07:09:31

Remove stray white spaces.

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