source: rtems/testsuites/tmtests/tm27/task1.c @ 0720ff4

4.104.114.84.95
Last change on this file since 0720ff4 was 0720ff4, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/28/04 at 07:20:11

2004-03-28 Ralf Corsepius <ralf_corsepius@…>

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