source: rtems/c/src/tests/tmtests/tm27/task1.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 1995 at 5:39:37 PM

Initial revision

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
4 *  On-Line Applications Research Corporation (OAR).
5 *  All rights assigned to U.S. Government, 1994.
6 *
7 *  This material may be reproduced by or for the U.S. Government pursuant
8 *  to the copyright license under the clause at DFARS 252.227-7013.  This
9 *  notice must appear in all copies of this file and its derivatives.
10 *
11 *  $Id$
12 */
13
14#include "system.h"
15#undef EXTERN
16#define EXTERN
17#include "conftbl.h"
18#include "gvar.h"
19
20#include <bsp.h>
21
22rtems_task Task_1(
23  rtems_task_argument argument
24);
25
26rtems_task Task_2(
27  rtems_task_argument argument
28);
29
30volatile rtems_unsigned32 Interrupt_occurred;
31volatile rtems_unsigned32 Interrupt_enter_time, Interrupt_enter_nested_time;
32volatile rtems_unsigned32 Interrupt_return_time, Interrupt_return_nested_time;
33rtems_unsigned32 Interrupt_nest;
34
35rtems_isr Isr_handler(
36  rtems_vector_number vector
37);
38
39/*
40 *  INTERNAL RTEMS VARIABLES!!!
41 */
42
43extern rtems_unsigned32 _Thread_Dispatch_disable_level;
44extern rtems_unsigned32 _Context_Switch_necessary;
45extern Chain_Control *_Thread_Ready_chain;
46extern rtems_tcb     *_Thread_Heir;
47
48rtems_task Init(
49  rtems_task_argument argument
50)
51{
52  rtems_status_code status;
53
54  puts( "\n\n*** TIME TEST 27 ***" );
55
56  status = rtems_task_create(
57    rtems_build_name( 'T', 'A', '1', ' ' ),
58    254,
59    1024,
60    RTEMS_DEFAULT_MODES,
61    RTEMS_DEFAULT_ATTRIBUTES,
62    &Task_id[ 1 ]
63  );
64  directive_failed( status, "rtems_task_create Task_1" );
65
66  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
67  directive_failed( status, "rtems_task_start Task_1" );
68
69  status = rtems_task_create(
70    rtems_build_name( 'T', 'A', '2', ' ' ),
71    254,
72    1024,
73    RTEMS_DEFAULT_MODES,
74    RTEMS_DEFAULT_ATTRIBUTES,
75    &Task_id[ 2 ]
76  );
77  directive_failed( status, "rtems_task_create of Task_2" );
78
79  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
80  directive_failed( status, "rtems_task_start of Task_2" );
81
82  status = rtems_task_delete( RTEMS_SELF );
83  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
84}
85
86rtems_task Task_1(
87  rtems_task_argument argument
88)
89{
90  _Thread_Dispatch_disable_level = 1;
91
92  Interrupt_nest = 1;
93
94  Install_tm27_vector( Isr_handler );
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_ENTER (nested interrupt)",
108    Interrupt_enter_nested_time,
109    1,
110    0,
111    0
112  );
113
114  put_time(
115    "INTERRUPT_RETURN (nested interrupt)",
116    Interrupt_return_nested_time,
117    1,
118    0,
119    0
120  );
121
122  Interrupt_nest = 0;
123
124  _Thread_Dispatch_disable_level = 0;
125
126  Interrupt_occurred = 0;
127  Timer_initialize();
128    Cause_tm27_intr();
129  /* goes to Isr_handler */
130
131#if (MUST_WAIT_FOR_INTERRUPT == 1)
132  while ( Interrupt_occurred == 0 );
133#endif
134  Interrupt_return_time = Read_timer();
135
136  put_time(
137    "INTERRUPT_ENTER (no preempt)",
138    Interrupt_enter_time,
139    1,
140    0,
141    0
142  );
143
144  put_time(
145    "INTERRUPT_RETURN (no preempt)",
146    Interrupt_return_time,
147    1,
148    0,
149    0
150  );
151
152  _Thread_Dispatch_disable_level = 0;
153
154  _Thread_Heir = (rtems_tcb *) _Thread_Ready_chain[254].last;
155
156  _Context_Switch_necessary = 1;
157
158  Interrupt_occurred = 0;
159  Timer_initialize();
160    Cause_tm27_intr();
161  /* goes to Isr_handler */
162}
163
164rtems_task Task_2(
165  rtems_task_argument argument
166)
167{
168#if (MUST_WAIT_FOR_INTERRUPT == 1)
169  while ( Interrupt_occurred == 0 );
170#endif
171  end_time = Read_timer();
172
173  put_time(
174    "INTERRUPT_ENTER (preempt)",
175    Interrupt_enter_time,
176    1,
177    0,
178    0
179  );
180
181  put_time(
182    "INTERRUPT_RETURN (preempt)",
183    end_time,
184    1,
185    0,
186    0
187  );
188
189  exit( 0 );
190}
191
192/*  The Isr_handler() and Isr_handler_inner() routines are structured
193 *  so that there will be as little entry overhead as possible included
194 *  in the interrupt entry time.
195 */
196
197void Isr_handler_inner( void );
198
199rtems_isr Isr_handler(
200  rtems_vector_number vector
201)
202{
203  end_time = Read_timer();
204
205  Interrupt_occurred = 1;
206  Isr_handler_inner();
207}
208
209void Isr_handler_inner( void )
210{
211
212  /*enable_tracing();*/
213  Clear_tm27_intr();
214  switch ( Interrupt_nest ) {
215    case 0:
216      Interrupt_enter_time = end_time;
217      break;
218    case 1:
219      Interrupt_enter_time = end_time;
220      Interrupt_nest = 2;
221      Interrupt_occurred = 0;
222      Lower_tm27_intr();
223      Timer_initialize();
224        Cause_tm27_intr();
225      /* goes to a nested copy of Isr_handler */
226#if (MUST_WAIT_FOR_INTERRUPT == 1)
227       while ( Interrupt_occurred == 0 );
228#endif
229      Interrupt_return_nested_time = Read_timer();
230      break;
231    case 2:
232      Interrupt_enter_nested_time = end_time;
233      break;
234  }
235
236  Timer_initialize();
237}
Note: See TracBrowser for help on using the repository browser.