source: rtems/c/src/tests/libtests/rtems++/Task2.cc @ 0074691a

4.104.114.84.95
Last change on this file since 0074691a was 0074691a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/31/97 at 22:13:29

Merged very large and much appreciated patch from Chris Johns
<cjohns@…>. This patch includes the ods68302 bsp,
the RTEMS++ class library, and the rtems++ test.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*  Task_2
2 *
3 *  This routine serves as a test task.  Its only purpose is to generate the
4 *  error where a semaphore is deleted while a task is waiting for it.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-1997.
12 *  On-Line Applications Research Corporation (OAR).
13 *  Copyright assigned to U.S. Government, 1994.
14 *
15 *  The license and distribution terms for this file may in
16 *  the file LICENSE in this distribution or at
17 *  http://www.OARcorp.com/rtems/license.html.
18 *
19 *  $Id$
20 */
21
22#include "System.h"
23
24Task2::Task2(const char* name,
25             const rtems_task_priority initial_priority,
26             const rtems_unsigned32 stack_size)
27  : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
28{
29}
30 
31void Task2::body(rtems_task_argument )
32{
33  screen4();
34
35  printf("%s - destory itself\n", name_string());
36  destroy();
37}
38
39void Task2::screen4()
40{
41  rtemsEvent event;
42
43  // block waiting for any event
44  rtems_event_set out;
45 
46  printf("%s - event no wait - ", name_string());
47  event.receive(RTEMS_SIGNAL_0, out, 0, rtemsEvent::no_wait);
48  printf("%s\n", event.last_status_string());
49 
50  printf("%s - event 5 secs timeout - ", name_string()); fflush(stdout);
51  event.receive(RTEMS_SIGNAL_0, out, 5000000);
52  printf("%s\n", event.last_status_string());
53
54  // send using task id
55  printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string());
56  event.receive(RTEMS_SIGNAL_0, out);
57  printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out);
58
59  // send using task object reference
60  printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string());
61  event.receive(RTEMS_SIGNAL_0, out);
62  printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out);
63 
64  printf("%s - event wait forever for signal 31 from TA1 ....\n", name_string());
65  event.receive(RTEMS_SIGNAL_31, out);
66  printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out);
67 
68  printf("%s - event wait forever for signal 0 and 31 from TA1 ....\n", name_string());
69  event.receive(RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31, out, 0, rtemsEvent::wait, rtemsEvent::all);
70  printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out);
71
72  printf("%s - send event signal 1 - ", name_string());
73  event.send(RTEMS_SIGNAL_1);
74  printf("%s\n", event.last_status_string());
75 
76  printf("%s - event wait forever for signal 1 from TA2 - ", name_string());
77  event.receive(RTEMS_SIGNAL_1, out, 0, rtemsEvent::wait, rtemsEvent::all);
78  printf("%s, signals out are 0x%08X\n", event.last_status_string(), out); 
79}
80
81
Note: See TracBrowser for help on using the repository browser.