source: rtems/c/src/tests/sptests/sp11/task1.c @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 1995 at 5:39:37 PM

Initial revision

  • Property mode set to 100644
File size: 11.7 KB
Line 
1/*  Task_1
2 *
3 *  This routine serves as a test task.  It verifies the event maager.
4 *
5 *  Input parameters:
6 *    argument - task argument
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  This material may be reproduced by or for the U.S. Government pursuant
15 *  to the copyright license under the clause at DFARS 252.227-7013.  This
16 *  notice must appear in all copies of this file and its derivatives.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23rtems_task Task_1(
24  rtems_task_argument argument
25)
26{
27  rtems_event_set   eventout;
28  rtems_time_of_day time;
29  rtems_status_code status;
30  rtems_unsigned32  index;
31
32  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_16 to TA2" );
33  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_16 );
34  directive_failed( status, "rtems_event_send" );
35
36  puts(
37    "TA1 - rtems_event_receive - waiting forever on "
38      "RTEMS_EVENT_14 and RTEMS_EVENT_15"
39  );
40  status = rtems_event_receive(
41    RTEMS_EVENT_14 | RTEMS_EVENT_15,
42    RTEMS_DEFAULT_OPTIONS,
43    RTEMS_NO_TIMEOUT,
44    &eventout
45  );
46  directive_failed( status, "rtems_event_receive" );
47  printf(
48    "TA1 - RTEMS_EVENT_14 and RTEMS_EVENT_15 received - eventout => %08x\n",
49    eventout
50  );
51
52  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to TA2" );
53  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_18 );
54  directive_failed( status, "rtems_event_send" );
55
56  puts(
57  "TA1 - rtems_event_receive - waiting with 10 second timeout on RTEMS_EVENT_14"
58  );
59  status = rtems_event_receive(
60    RTEMS_EVENT_14,
61    RTEMS_DEFAULT_OPTIONS,
62    10 * TICKS_PER_SECOND,
63    &eventout
64  );
65  directive_failed( status, "rtems_event_receive" );
66  printf( "TA1 - RTEMS_EVENT_14 received - eventout => %08x\n", eventout );
67
68  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_19 to TA2" );
69  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_19 );
70  directive_failed( status, "rtems_event_send" );
71
72  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
73  directive_failed( status, "rtems_clock_get" );
74  print_time( "TA1 - rtems_clock_get - ", &time, "\n" );
75
76pause();
77
78  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to self after 5 seconds");
79  status = rtems_timer_fire_after(
80    Timer_id[ 1 ],
81    5 * TICKS_PER_SECOND,
82    TA1_send_18_to_self_5_seconds,
83    NULL
84  );
85  directive_failed( status, "rtems_timer_fire_after 5 seconds" );
86
87  puts( "TA1 - rtems_event_receive - waiting forever on RTEMS_EVENT_18"  );
88  status = rtems_event_receive(
89    RTEMS_EVENT_18,
90    RTEMS_DEFAULT_OPTIONS,
91    RTEMS_NO_TIMEOUT,
92    &eventout
93  );
94  directive_failed( status, "rtems_event_receive of 18" );
95  printf( "TA1 - RTEMS_EVENT_18 received - eventout => %08x\n", eventout );
96
97  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
98  directive_failed( status, "TA1 rtems_clock_get" );
99  print_time( "TA1 - rtems_clock_get - ", &time, "\n" );
100
101  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_3 to self" );
102  status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_3 );
103  directive_failed( status, "rtems_event_send" );
104
105  puts(
106    "TA1 - rtems_event_receive - RTEMS_EVENT_3 or "
107      "RTEMS_EVENT_22 - NO_WAIT and ANY"
108  );
109  status = rtems_event_receive(
110    RTEMS_EVENT_3 | RTEMS_EVENT_22,
111    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
112    RTEMS_NO_TIMEOUT,
113    &eventout
114  );
115  directive_failed( status, "rtems_event_receive of 3 and 22" );
116  printf( "TA1 - RTEMS_EVENT_3 received - eventout => %08x\n", eventout );
117
118  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_4 to self" );
119  status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_4 );
120  directive_failed( status, "rtems_event_send" );
121
122  puts (
123  "TA1 - rtems_event_receive - RTEMS_EVENT_4 or "
124      "RTEMS_EVENT_5 - forever and ANY"
125  );
126  status = rtems_event_receive(
127    RTEMS_EVENT_4 | RTEMS_EVENT_5,
128    RTEMS_EVENT_ANY,
129    RTEMS_NO_TIMEOUT,
130    &eventout
131  );
132  directive_failed( status, "rtems_event_receive" );
133  printf( "TA1 - RTEMS_EVENT_4 received - eventout => %08x\n", eventout );
134
135pause();
136
137  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to self after 5 seconds");
138  status = rtems_timer_fire_after(
139    Timer_id[ 1 ],
140    5 * TICKS_PER_SECOND,
141    TA1_send_18_to_self_5_seconds,
142    NULL
143  );
144  directive_failed( status, "rtems_timer_fire_after 5 seconds" );
145
146  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_18");
147  status = rtems_timer_cancel( Timer_id[ 1 ] );
148  directive_failed( status, "rtems_timer_cancel" );
149
150  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_8 to self after 60 seconds");
151  status = rtems_timer_fire_after(
152    Timer_id[ 1 ],
153    60 * TICKS_PER_SECOND,
154    TA1_send_8_to_self_60_seconds,
155    NULL
156  );
157  directive_failed( status, "rtems_timer_fire_after 60 seconds" );
158
159  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_9 to self after 60 seconds");
160  status = rtems_timer_fire_after(
161    Timer_id[ 2 ],
162    60 * TICKS_PER_SECOND,
163    TA1_send_9_to_self_60_seconds,
164    NULL
165  );
166  directive_failed( status, "rtems_timer_fire_after 60 seconds" );
167
168  puts(
169    "TA1 - rtems_event_send - send RTEMS_EVENT_10 to self after 60 seconds"
170  );
171  status = rtems_timer_fire_after(
172    Timer_id[ 3 ],
173    60 * TICKS_PER_SECOND,
174    TA1_send_10_to_self,
175    NULL
176  );
177  directive_failed( status, "rtems_timer_fire_after 60 seconds" );
178
179  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_8" );
180  status = rtems_timer_cancel( Timer_id[ 1 ] );
181  directive_failed( status, "rtems_timer_cancel" );
182
183  build_time( &time, 2, 12, 1988, 8, 15, 0, 0 );
184
185  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
186  status = rtems_clock_set( &time );
187  directive_failed( status, "rtems_clock_set" );
188
189  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_1 every second" );
190  status = rtems_timer_fire_after(
191    Timer_id[ 1 ],
192    TICKS_PER_SECOND,
193    TA1_send_1_to_self_every_second,
194    NULL
195  );
196  directive_failed( status, "rtems_timer_fire_after 1 second" );
197
198  for ( index = 0; index < 3; index++ ) {
199
200    status = rtems_event_receive(
201      RTEMS_EVENT_1,
202      RTEMS_EVENT_ANY,
203      RTEMS_NO_TIMEOUT,
204      &eventout
205    );
206    directive_failed( status, "rtems_event_receive" );
207
208    status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
209    directive_failed( status, "rtems_clock_get" );
210
211    printf( "TA1 - RTEMS_EVENT_1 received - eventout => %08x - ", eventout );
212    print_time( "at ", &time, "\n" );
213
214    if ( index < 2 ) {
215      status = rtems_timer_reset( Timer_id[ 1 ] );
216      directive_failed( status, "rtems_timer_reset" );
217    };
218
219  }
220
221  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_1" );
222  status = rtems_timer_cancel( Timer_id[ 1 ] );
223  directive_failed( status, "rtems_timer_cancel" );
224
225pause();
226
227  time.day = 13;
228  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 1 day" );
229  status = rtems_timer_fire_when(
230    Timer_id[ 1 ],
231    &time,
232    TA1_send_11_to_self,
233    NULL
234  );
235  directive_failed( status, "rtems_timer_fire_when 1 day" );
236
237  time.hour = 7;
238  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 1 day" );
239  status = rtems_timer_fire_when(
240    Timer_id[ 2 ],
241    &time,
242    TA1_send_11_to_self,
243    NULL
244  );
245  directive_failed( status, "rtems_timer_fire_when 1 day" );
246
247  time.hour = 8;   /* so code below has correct time/date */
248  time.day = 14;
249  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 2 days" );
250  status = rtems_timer_fire_when(
251    Timer_id[ 3 ],
252    &time,
253    TA1_send_11_to_self,
254    NULL
255  );
256  directive_failed( status, "rtems_timer_fire_when 2 days" );
257
258  puts("TA1 - rtems_timer_cancel - cancelling RTEMS_EVENT_11 to self in 1 day");
259  status = rtems_timer_cancel( Timer_id[ 1 ] );
260  directive_failed( status, "rtems_timer_cancel" );
261
262  puts(
263    "TA1 - rtems_timer_cancel - cancelling RTEMS_EVENT_11 to self in 2 days"
264  );
265  status = rtems_timer_cancel( Timer_id[ 3 ] );
266  directive_failed( status, "rtems_timer_cancel" );
267
268  puts(
269    "TA1 - rtems_event_send - resending RTEMS_EVENT_11 to self in 2 days"
270  );
271  status = rtems_timer_fire_when(
272    Timer_id[ 3 ],
273    &time,
274    TA1_send_11_to_self,
275    NULL
276  );
277  directive_failed( status, "rtems_timer_fire_when 2 days" );
278
279  time.day = 15;
280  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
281  status = rtems_clock_set( &time );
282  directive_failed( status, "TA1 rtems_clock_set" );
283
284  puts( "TA1 - rtems_event_receive - waiting forever on RTEMS_EVENT_11" );
285  status = rtems_event_receive(
286    RTEMS_EVENT_11,
287    RTEMS_DEFAULT_OPTIONS,
288    RTEMS_NO_TIMEOUT,
289    &eventout
290  );
291  directive_failed( status, "rtems_event_receive" );
292  printf( "TA1 - RTEMS_EVENT_11 received - eventout => %08x\n", eventout );
293
294pause();
295
296  puts( "TA1 - rtems_event_send/rtems_event_receive combination" );
297  status = rtems_timer_fire_after(
298    Timer_id[ 1 ],
299    10,
300    TA1_send_11_to_self,
301    NULL
302  );
303  directive_failed( status, "rtems_timer_fire_after 10 ticks" );
304
305  status = rtems_event_receive(
306    RTEMS_EVENT_11,
307    RTEMS_DEFAULT_OPTIONS,
308    RTEMS_NO_TIMEOUT,
309    &eventout
310  );
311  directive_failed( status, "rtems_event_receive" );
312
313  build_time( &time, 2, 12, 1988, 8, 15, 0, 0 );
314
315  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
316  status = rtems_clock_set( &time );
317  directive_failed( status, "rtems_clock_set" );
318
319  time.day = 13;
320  puts( "TA1 - rtems_event_receive all outstanding events" );
321  status  = rtems_event_receive(
322    RTEMS_ALL_EVENTS,
323    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
324    0,
325    &eventout
326  );
327  fatal_directive_status(
328    status,
329    RTEMS_UNSATISFIED,
330    "rtems_event_receive all events"
331  );
332
333  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_10 to self in 1 day" );
334  status = rtems_timer_fire_when(
335    Timer_id[ 1 ],
336    &time,
337    TA1_send_10_to_self,
338    NULL
339  );
340  directive_failed( status, "rtems_timer_fire_when 1 day" );
341
342  time.day = 14;
343  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 2 days" );
344  status = rtems_timer_fire_when(
345    Timer_id[ 2 ],
346    &time,
347    TA1_send_11_to_self,
348    NULL
349  );
350  directive_failed( status, "rtems_timer_fire_when 2 days" );
351
352  build_time( &time, 2, 12, 1988, 7, 15, 0, 0 );
353
354  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
355  puts( "TA1 - set time backwards" );
356  status = rtems_clock_set( &time );
357  directive_failed( status, "rtems_clock_set" );
358
359  status  = rtems_event_receive(
360    RTEMS_ALL_EVENTS,
361    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
362    RTEMS_NO_TIMEOUT,
363    &eventout
364  );
365  if ( eventout ) printf( "ERROR -0x%08x events received\n", eventout );
366  else            puts( "TA1 - no events received" );
367  fatal_directive_status(
368    status,
369    RTEMS_UNSATISFIED,
370    "rtems_event_receive all events"
371  );
372
373  build_time( &time, 2, 14, 1988, 7, 15, 0, 0 );
374
375  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
376  puts( "TA1 - set time forwards (leave a timer)" );
377  status = rtems_clock_set( &time );
378  directive_failed( status, "rtems_clock_set" );
379
380  status  = rtems_event_receive(
381    RTEMS_ALL_EVENTS,
382    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
383    RTEMS_NO_TIMEOUT,
384    &eventout
385  );
386  if ( eventout == RTEMS_EVENT_10 ) puts( "TA1 - RTEMS_EVENT_10 received" );
387  else      printf( "ERROR -0x%08x events received\n", eventout );
388  directive_failed( status, "rtems_event_receive all events" );
389
390  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 100 ticks");
391  status = rtems_timer_fire_after(
392    Timer_id[ 1 ],
393    100,
394    TA1_send_11_to_self,
395    NULL
396  );
397  directive_failed( status, "rtems_timer_fire_after 100 ticks" );
398
399  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 200 ticks");
400  status = rtems_timer_fire_after(
401    Timer_id[ 1 ],
402    200,
403    TA1_send_11_to_self,
404    NULL
405  );
406  directive_failed( status, "rtems_timer_fire_after 200 ticks" );
407
408  puts( "*** END OF TEST 11 ***" );
409  exit( 0 );
410}
Note: See TracBrowser for help on using the repository browser.