source: rtems/testsuites/tmtests/tm27/task1.c @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

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