source: rtems/testsuites/tmtests/tm23/task1.c @ 3652ad35

4.104.114.84.95
Last change on this file since 3652ad35 was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 19, 1995 at 2:53:29 PM

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