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

4.104.114.84.95
Last change on this file since ea74482 was ea74482, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 11, 1995 at 1:54:46 PM

reordered test cases from simple to complex

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