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
81
82
|
/* 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.rtems.com/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "System.h"
Task2::Task2(const char* name,
const rtems_task_priority initial_priority,
const uint32_t 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%08" PRIX32 "\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%08" PRIX32 "\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%08" PRIX32 "\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%08" PRIX32 "\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%08" PRIX32 "\n", event.last_status_string(), out);
}
|