summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/rtems++/Task2.cc
blob: 1a44f4b0ef6af083d4fd38b99e0b113940191fc6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*  Task_2
 *
 *  This routine serves as a test task.  Its only purpose is to generate the
 *  error where a semaphore is deleted while a task is waiting for it.
 *
 *  Input parameters:
 *    argument - task argument
 *
 *  Output parameters:  NONE
 *
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#include "System.h"

Task2::Task2(const char* name,
             const rtems_task_priority initial_priority,
             const rtems_unsigned32 stack_size)
  : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
{
}
  
void Task2::body(rtems_task_argument )
{
  screen4();

  printf("%s - destroy itself\n", name_string());
  destroy();
}

void Task2::screen4()
{
  rtemsEvent event;

  // block waiting for any event
  rtems_event_set out;
  
  printf("%s - event no wait - ", name_string());
  event.receive(RTEMS_SIGNAL_0, out, 0, rtemsEvent::no_wait);
  printf("%s\n", event.last_status_string());
  
  printf("%s - event 5 secs timeout - ", name_string()); fflush(stdout);
  event.receive(RTEMS_SIGNAL_0, out, 5000000);
  printf("%s\n", event.last_status_string());

  // send using task id
  printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string());
  event.receive(RTEMS_SIGNAL_0, out);
  printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out);

  // send using task object reference
  printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string());
  event.receive(RTEMS_SIGNAL_0, out);
  printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out);
  
  printf("%s - event wait forever for signal 31 from TA1 ....\n", name_string());
  event.receive(RTEMS_SIGNAL_31, out);
  printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out);
  
  printf("%s - event wait forever for signal 0 and 31 from TA1 ....\n", name_string());
  event.receive(RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31, out, 0, rtemsEvent::wait, rtemsEvent::all);
  printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out);

  printf("%s - send event signal 1 - ", name_string());
  event.send(RTEMS_SIGNAL_1);
  printf("%s\n", event.last_status_string());
  
  printf("%s - event wait forever for signal 1 from TA2 - ", name_string());
  event.receive(RTEMS_SIGNAL_1, out, 0, rtemsEvent::wait, rtemsEvent::all);
  printf("%s, signals out are 0x%08X\n", event.last_status_string(), out);  
}