source: rtems/testsuites/libtests/rtems++/Task2.cc @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.7 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-1999.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include "System.h"
24
25Task2::Task2(const char* name,
26             const rtems_task_priority initial_priority,
27             const uint32_t   stack_size)
28  : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
29{
30}
31 
32void Task2::body(rtems_task_argument )
33{
34  screen4();
35
36  printf("%s - destroy itself\n", name_string());
37  destroy();
38}
39
40void Task2::screen4()
41{
42  rtemsEvent event;
43
44  // block waiting for any event
45  rtems_event_set out;
46 
47  printf("%s - event no wait - ", name_string());
48  event.receive(RTEMS_SIGNAL_0, out, 0, rtemsEvent::no_wait);
49  printf("%s\n", event.last_status_string());
50 
51  printf("%s - event 5 secs timeout - ", name_string()); fflush(stdout);
52  event.receive(RTEMS_SIGNAL_0, out, 5000000);
53  printf("%s\n", event.last_status_string());
54
55  // send using task id
56  printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string());
57  event.receive(RTEMS_SIGNAL_0, out);
58  printf("%s - %s, signals out are 0x%08" PRIX32 "\n", name_string(), event.last_status_string(), out);
59
60  // send using task object reference
61  printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string());
62  event.receive(RTEMS_SIGNAL_0, out);
63  printf("%s - %s, signals out are 0x%08" PRIX32 "\n", name_string(), event.last_status_string(), out);
64 
65  printf("%s - event wait forever for signal 31 from TA1 ....\n", name_string());
66  event.receive(RTEMS_SIGNAL_31, out);
67  printf("%s - %s, signals out are 0x%08" PRIX32 "\n", name_string(), event.last_status_string(), out);
68 
69  printf("%s - event wait forever for signal 0 and 31 from TA1 ....\n", name_string());
70  event.receive(RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31, out, 0, rtemsEvent::wait, rtemsEvent::all);
71  printf("%s - %s, signals out are 0x%08" PRIX32 "\n", name_string(), event.last_status_string(), out);
72
73  printf("%s - send event signal 1 - ", name_string());
74  event.send(RTEMS_SIGNAL_1);
75  printf("%s\n", event.last_status_string());
76 
77  printf("%s - event wait forever for signal 1 from TA2 - ", name_string());
78  event.receive(RTEMS_SIGNAL_1, out, 0, rtemsEvent::wait, rtemsEvent::all);
79  printf("%s, signals out are 0x%08" PRIX32 "\n", event.last_status_string(), out); 
80}
81
82
Note: See TracBrowser for help on using the repository browser.