source: rtems/testsuites/tmtests/tm27/task1.c @ 38ffa0c

4.104.114.84.95
Last change on this file since 38ffa0c was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on 09/19/95 at 14:53:29

Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size
macro to include other types of objects and the increase in the
minimum stack size for most CPUs.

  • Property mode set to 100644
File size: 4.7 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  _Thread_Dispatch_disable_level = 1;
90
91  Interrupt_nest = 1;
92
93  Install_tm27_vector( Isr_handler );
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_ENTER (nested interrupt)",
107    Interrupt_enter_nested_time,
108    1,
109    0,
110    0
111  );
112
113  put_time(
114    "INTERRUPT_RETURN (nested interrupt)",
115    Interrupt_return_nested_time,
116    1,
117    0,
118    0
119  );
120
121  Interrupt_nest = 0;
122
123  _Thread_Dispatch_disable_level = 0;
124
125  Interrupt_occurred = 0;
126  Timer_initialize();
127    Cause_tm27_intr();
128  /* goes to Isr_handler */
129
130#if (MUST_WAIT_FOR_INTERRUPT == 1)
131  while ( Interrupt_occurred == 0 );
132#endif
133  Interrupt_return_time = Read_timer();
134
135  put_time(
136    "INTERRUPT_ENTER (no preempt)",
137    Interrupt_enter_time,
138    1,
139    0,
140    0
141  );
142
143  put_time(
144    "INTERRUPT_RETURN (no preempt)",
145    Interrupt_return_time,
146    1,
147    0,
148    0
149  );
150
151  _Thread_Dispatch_disable_level = 0;
152
153  _Thread_Heir = (rtems_tcb *) _Thread_Ready_chain[254].last;
154
155  _Context_Switch_necessary = 1;
156
157  Interrupt_occurred = 0;
158  Timer_initialize();
159    Cause_tm27_intr();
160  /* goes to Isr_handler */
161}
162
163rtems_task Task_2(
164  rtems_task_argument argument
165)
166{
167#if (MUST_WAIT_FOR_INTERRUPT == 1)
168  while ( Interrupt_occurred == 0 );
169#endif
170  end_time = Read_timer();
171
172  put_time(
173    "INTERRUPT_ENTER (preempt)",
174    Interrupt_enter_time,
175    1,
176    0,
177    0
178  );
179
180  put_time(
181    "INTERRUPT_RETURN (preempt)",
182    end_time,
183    1,
184    0,
185    0
186  );
187
188  puts( "*** END OF TEST 27 ***" );
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.