OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [tests/] [tmtests/] [tm27/] [task1.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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.OARcorp.com/rtems/license.html.
9
 *
10
 *  task1.c,v 1.15 2002/08/02 00:52:37 joel Exp
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
 
25
rtems_task Task_1(
26
  rtems_task_argument argument
27
);
28
 
29
rtems_task Task_2(
30
  rtems_task_argument argument
31
);
32
 
33
volatile rtems_unsigned32 Interrupt_occurred;
34
volatile rtems_unsigned32 Interrupt_enter_time, Interrupt_enter_nested_time;
35
volatile rtems_unsigned32 Interrupt_return_time, Interrupt_return_nested_time;
36
rtems_unsigned32 Interrupt_nest;
37
rtems_unsigned32 timer_overhead;
38
 
39
rtems_isr Isr_handler(
40
  rtems_vector_number vector
41
);
42
 
43
rtems_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
 
88
rtems_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
  put_time(
148
    "interrupt entry overhead: returns to nested interrupt",
149
    Interrupt_enter_nested_time,
150
    1,
151
    0,
152
 
153
  );
154
 
155
  put_time(
156
    "interrupt exit overhead: returns to nested interrupt",
157
    Interrupt_return_nested_time,
158
    1,
159
    0,
160
 
161
  );
162
 
163
  /*
164
   *  Does a preempt .. not nested
165
   */
166
 
167
  _Thread_Dispatch_disable_level = 0;
168
 
169
  _Thread_Heir = (rtems_tcb *) _Thread_Ready_chain[254].last;
170
 
171
  _Context_Switch_necessary = 1;
172
 
173
  Interrupt_occurred = 0;
174
  Timer_initialize();
175
  Cause_tm27_intr();
176
 
177
  /*
178
   *  goes to Isr_handler and then returns
179
   */
180
 
181
  puts( "*** END OF TEST 27 ***" );
182
  rtems_test_exit( 0 );
183
}
184
 
185
/*
186
 *  NOTE:  When this task is executing, some of the assumptions made
187
 *         regarding the placement of the currently executing task's TCB
188
 *         on the ready chains have been violated.  At least the assumption
189
 *         that this task is at the head of the chain for its priority
190
 *         has been violated.
191
 */
192
 
193
rtems_task Task_2(
194
  rtems_task_argument argument
195
)
196
{
197
#if (MUST_WAIT_FOR_INTERRUPT == 1)
198
  while ( Interrupt_occurred == 0 );
199
#endif
200
  end_time = Read_timer();
201
 
202
  put_time(
203
    "interrupt entry overhead: returns to preempting task",
204
    Interrupt_enter_time,
205
    1,
206
    0,
207
    timer_overhead
208
  );
209
 
210
  put_time(
211
    "interrupt exit overhead: returns to preempting task",
212
    end_time,
213
    1,
214
    0,
215
 
216
  );
217
 
218
  fflush( stdout );
219
 
220
  /*
221
   *  Switch back to the other task to exit the test.
222
   */
223
 
224
  _Thread_Dispatch_disable_level = 0;
225
 
226
  _Thread_Heir = (rtems_tcb *) _Thread_Ready_chain[254].first;
227
 
228
  _Context_Switch_necessary = 1;
229
 
230
  _Thread_Dispatch();
231
 
232
}
233
 
234
/*  The Isr_handler() and Isr_handler_inner() routines are structured
235
 *  so that there will be as little entry overhead as possible included
236
 *  in the interrupt entry time.
237
 */
238
 
239
void Isr_handler_inner( void );
240
 
241
rtems_isr Isr_handler(
242
  rtems_vector_number vector
243
)
244
{
245
  end_time = Read_timer();
246
 
247
  Interrupt_occurred = 1;
248
  Isr_handler_inner();
249
}
250
 
251
void Isr_handler_inner( void )
252
{
253
 
254
  /*enable_tracing();*/
255
  Clear_tm27_intr();
256
  switch ( Interrupt_nest ) {
257
    case 0:
258
      Interrupt_enter_time = end_time;
259
      break;
260
    case 1:
261
      Interrupt_enter_time = end_time;
262
      Interrupt_nest = 2;
263
      Interrupt_occurred = 0;
264
      Lower_tm27_intr();
265
      Timer_initialize();
266
      Cause_tm27_intr();
267
      /* goes to a nested copy of Isr_handler */
268
#if (MUST_WAIT_FOR_INTERRUPT == 1)
269
       while ( Interrupt_occurred == 0 );
270
#endif
271
      Interrupt_return_nested_time = Read_timer();
272
      break;
273
    case 2:
274
      Interrupt_enter_nested_time = end_time;
275
      break;
276
  }
277
 
278
  Timer_initialize();
279
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.