source: rtems/c/src/tests/tmtests/tm23/task1.c @ 4b374f36

4.104.114.84.95
Last change on this file since 4b374f36 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 6.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#include "system.h"
15#undef EXTERN
16#define EXTERN
17#include "conftbl.h"
18#include "gvar.h"
19
20rtems_id          Timer_id[ OPERATION_COUNT+1 ];
21
22rtems_time_of_day time_of_day;
23
24void null_delay(
25  rtems_id  ignored_id,
26  void     *ignored_address
27);
28
29rtems_task Low_task(
30  rtems_task_argument argument
31);
32
33rtems_task Middle_tasks(
34  rtems_task_argument argument
35);
36
37rtems_task High_task(
38  rtems_task_argument argument
39);
40
41
42rtems_task Init(
43  rtems_task_argument argument
44)
45{
46
47  rtems_task_priority priority;
48  rtems_unsigned32    index;
49  rtems_id            id;
50  rtems_task_entry    task_entry;
51  rtems_status_code   status;
52
53  puts( "\n\n*** TIME TEST 23 ***" );
54
55  Timer_initialize();
56    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
57      (void) Empty_function();
58  overhead = Read_timer();
59
60  priority = 5;
61
62  for( index=1 ; index <= OPERATION_COUNT ; index++ ) {
63    status = rtems_task_create(
64      rtems_build_name( 'T', 'I', 'M', 'E' ),
65      priority,
66      1024,
67      RTEMS_DEFAULT_MODES,
68      RTEMS_DEFAULT_ATTRIBUTES,
69      &id
70    );
71    directive_failed( status, "rtems_task_create LOOP" );
72
73    if ( index == 1 )                    task_entry = High_task;
74    else if ( index == OPERATION_COUNT ) task_entry = Low_task;
75    else                                 task_entry = Middle_tasks;
76
77    status = rtems_task_start( id, task_entry, 0 );
78    directive_failed( status, "rtems_task_start LOOP" );
79
80    priority++;
81  }
82
83  status = rtems_task_delete( RTEMS_SELF );
84  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
85}
86
87void null_delay(
88  rtems_id  ignored_id,
89  void     *ignored_address
90)
91{
92}
93
94rtems_task High_task(
95  rtems_task_argument argument
96)
97{
98  rtems_unsigned32  index;
99  rtems_status_code status;
100  int i;
101
102  Timer_initialize();
103    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
104      (void) Empty_function();
105  overhead = Read_timer();
106
107  Timer_initialize();
108    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
109      (void) rtems_timer_create( index, &Timer_id[ index ] );
110  end_time = Read_timer();
111
112  put_time(
113    "rtems_timer_create",
114    end_time,
115    OPERATION_COUNT,
116    overhead,
117    CALLING_OVERHEAD_TIMER_CREATE
118  );
119
120  Timer_initialize();
121    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
122      (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
123  end_time = Read_timer();
124
125  put_time(
126    "rtems_timer_fire_after (inactive)",
127    end_time,
128    OPERATION_COUNT,
129    overhead,
130    CALLING_OVERHEAD_TIMER_FIRE_AFTER
131  );
132
133  Timer_initialize();
134    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
135      (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
136  end_time = Read_timer();
137
138  put_time(
139    "rtems_timer_fire_after (active)",
140    end_time,
141    OPERATION_COUNT,
142    overhead,
143    CALLING_OVERHEAD_TIMER_FIRE_AFTER
144  );
145
146  Timer_initialize();
147    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
148      (void) rtems_timer_cancel( Timer_id[ index ] );
149  end_time = Read_timer();
150
151  put_time(
152    "rtems_timer_cancel (active)",
153    end_time,
154    OPERATION_COUNT,
155    overhead,
156    CALLING_OVERHEAD_TIMER_CANCEL
157  );
158
159  for ( Timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ )
160  Timer_initialize();
161    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
162      (void) rtems_timer_cancel( Timer_id[ index ] );
163  end_time = Read_timer();
164
165  put_time(
166    "rtems_timer_cancel (inactive)",
167    end_time,
168    OPERATION_COUNT,
169    overhead,
170    CALLING_OVERHEAD_TIMER_CANCEL
171  );
172
173  for ( Timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ )
174  Timer_initialize();
175    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
176      (void) rtems_timer_reset( Timer_id[ index ] );
177  end_time = Read_timer();
178
179  put_time(
180    "rtems_timer_reset (inactive)",
181    end_time,
182    OPERATION_COUNT,
183    overhead,
184    CALLING_OVERHEAD_TIMER_RESET
185  );
186
187  Timer_initialize();
188    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
189      (void) rtems_timer_reset( Timer_id[ index ] );
190  end_time = Read_timer();
191
192  put_time(
193    "rtems_timer_reset (active)",
194    end_time,
195    OPERATION_COUNT,
196    overhead,
197    CALLING_OVERHEAD_TIMER_RESET
198  );
199
200  for ( index=1 ; index <= OPERATION_COUNT ; index++ )
201    (void) rtems_timer_reset( Timer_id[ index ] );
202
203  build_time( &time_of_day, 12, 31, 1988, 9, 0, 0, 0 );
204
205  status = rtems_clock_set( &time_of_day );
206  directive_failed( status, "rtems_clock_set" );
207
208  time_of_day.year = 1989;
209
210  Timer_initialize();
211    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
212      (void) rtems_timer_fire_when(
213         Timer_id[ index ], &time_of_day, null_delay, NULL );
214  end_time = Read_timer();
215
216  put_time(
217    "rtems_timer_fire_when (inactive)",
218    end_time,
219    OPERATION_COUNT,
220    overhead,
221    CALLING_OVERHEAD_TIMER_FIRE_WHEN
222  );
223
224  Timer_initialize();
225    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
226      (void) rtems_timer_fire_when(
227         Timer_id[ index ], &time_of_day, null_delay, NULL );
228  end_time = Read_timer();
229
230  put_time(
231    "rtems_timer_fire_when (active)",
232    end_time,
233    OPERATION_COUNT,
234    overhead,
235    CALLING_OVERHEAD_TIMER_FIRE_WHEN
236  );
237
238  Timer_initialize();
239    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
240      (void) rtems_timer_delete( Timer_id[ index ] );
241  end_time = Read_timer();
242
243  put_time(
244    "rtems_timer_delete (active)",
245    end_time,
246    OPERATION_COUNT,
247    overhead,
248    CALLING_OVERHEAD_TIMER_DELETE
249  );
250
251  Timer_initialize();
252  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
253    status = rtems_timer_create( index, &Timer_id[ index ] );
254    directive_failed( status, "rtems_timer_create" );
255
256    status = rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
257    directive_failed( status, "rtems_timer_fire_after" );
258
259    status = rtems_timer_cancel( Timer_id[ index ] );
260    directive_failed( status, "rtems_timer_cancel" );
261  }
262
263  Timer_initialize();
264    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
265      (void) rtems_timer_delete( Timer_id[ index ] );
266  end_time = Read_timer();
267
268  put_time(
269    "rtems_timer_delete (inactive)",
270    end_time,
271    OPERATION_COUNT,
272    overhead,
273    CALLING_OVERHEAD_TIMER_DELETE
274  );
275
276  Timer_initialize();
277    (void) rtems_task_wake_when( &time_of_day );
278}
279
280rtems_task Middle_tasks(
281  rtems_task_argument argument
282)
283{
284  (void) rtems_task_wake_when( &time_of_day );
285}
286
287rtems_task Low_task(
288  rtems_task_argument argument
289)
290{
291  end_time = Read_timer();
292
293  put_time(
294    "rtems_task_wake_when",
295    end_time,
296    OPERATION_COUNT,
297    0,
298    CALLING_OVERHEAD_TASK_WAKE_WHEN
299  );
300
301  exit( 0 );
302}
Note: See TracBrowser for help on using the repository browser.