source: rtems/testsuites/tmtests/tm27/task1.c @ db941670

4.104.114.84.95
Last change on this file since db941670 was db941670, checked in by Joel Sherrill <joel.sherrill@…>, on 01/03/00 at 14:14:24

Added define to trip items that are private to tm27 in bsp.h.

  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[ac7d5ef0]1/*
2 *
[08311cc3]3 *  COPYRIGHT (c) 1989-1999.
[ac7d5ef0]4 *  On-Line Applications Research Corporation (OAR).
5 *
[98e4ebf5]6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
[03f2154e]8 *  http://www.OARcorp.com/rtems/license.html.
[ac7d5ef0]9 *
10 *  $Id$
11 */
12
[9700578]13/*
14 *  WARNING!!!!!!!!!   
15 *
16 *  THIS TEST USES INTERNAL RTEMS VARIABLES!!!
17 */
18
[3a4ae6c]19#define TEST_INIT
[ac7d5ef0]20#include "system.h"
21
[db941670]22#define RTEMS_TM27
[ac7d5ef0]23#include <bsp.h>
24
25rtems_task Task_1(
26  rtems_task_argument argument
27);
28
29rtems_task Task_2(
30  rtems_task_argument argument
31);
32
33volatile rtems_unsigned32 Interrupt_occurred;
34volatile rtems_unsigned32 Interrupt_enter_time, Interrupt_enter_nested_time;
35volatile rtems_unsigned32 Interrupt_return_time, Interrupt_return_nested_time;
36rtems_unsigned32 Interrupt_nest;
37
38rtems_isr Isr_handler(
39  rtems_vector_number vector
40);
41
42rtems_task Init(
43  rtems_task_argument argument
44)
45{
46  rtems_status_code status;
47
[3a4ae6c]48  Print_Warning();
49
[ac7d5ef0]50  puts( "\n\n*** TIME TEST 27 ***" );
51
52  status = rtems_task_create(
53    rtems_build_name( 'T', 'A', '1', ' ' ),
54    254,
[3652ad35]55    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]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,
[3652ad35]68    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]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
82rtems_task Task_1(
83  rtems_task_argument argument
84)
85{
[ea74482]86  Install_tm27_vector( Isr_handler );
[ac7d5ef0]87
[ea74482]88  /*
89   *  No preempt .. no nesting
90   */
[ac7d5ef0]91
[ea74482]92  Interrupt_nest = 0;
93
94  _Thread_Dispatch_disable_level = 0;
[ac7d5ef0]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(
[5c491aef]107    "interrupt entry overhead: returns to interrupted task",
[ea74482]108    Interrupt_enter_time,
[ac7d5ef0]109    1,
110    0,
111    0
112  );
113
114  put_time(
[5c491aef]115    "interrupt exit overhead: returns to interrupted task",
[ea74482]116    Interrupt_return_time,
[ac7d5ef0]117    1,
118    0,
119    0
120  );
121
[ea74482]122  /*
123   *  No preempt .. nested
124   */
[ac7d5ef0]125
[ea74482]126  _Thread_Dispatch_disable_level = 1;
127
128  Interrupt_nest = 1;
[ac7d5ef0]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(
[5c491aef]141    "interrupt entry overhead: returns to nested interrupt",
[ea74482]142    Interrupt_enter_nested_time,
[ac7d5ef0]143    1,
144    0,
145    0
146  );
147
148  put_time(
[5c491aef]149    "interrupt exit overhead: returns to nested interrupt",
[ea74482]150    Interrupt_return_nested_time,
[ac7d5ef0]151    1,
152    0,
153    0
154  );
155
[ea74482]156  /*
157   *  Does a preempt .. not nested
158   */
159
[ac7d5ef0]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();
[9700578]169
170  /*
171   *  goes to Isr_handler and then returns
172   */
173
174  puts( "*** END OF TEST 27 ***" );
175  exit( 0 );
[ac7d5ef0]176}
177
[9700578]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
[ac7d5ef0]186rtems_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(
[5c491aef]196    "interrupt entry overhead: returns to preempting task",
[ac7d5ef0]197    Interrupt_enter_time,
198    1,
199    0,
200    0
201  );
202
203  put_time(
[5c491aef]204    "interrupt exit overhead: returns to preempting task",
[ac7d5ef0]205    end_time,
206    1,
207    0,
208    0
209  );
210
[9700578]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
[ac7d5ef0]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
232void Isr_handler_inner( void );
233
234rtems_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
244void 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}
Note: See TracBrowser for help on using the repository browser.