summaryrefslogtreecommitdiffstats
path: root/c/src/exec/rtems/headers/event.h
blob: 48045bdadeb7e9004ee189db1188dcd017e5ec44 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*  event.h
 *
 *  This include file contains the information pertaining to the Event
 *  Manager.  This manager provides a high performance method of communication
 *  and synchronization.
 *
 *  Directives provided are:
 *
 *     + send an event set to a task
 *     + receive event condition
 *
 *
 *  COPYRIGHT (c) 1989-1998.
 *  On-Line Applications Research Corporation (OAR).
 *  Copyright assigned to U.S. Government, 1994.
 *
 *  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$
 */

#ifndef __RTEMS_EVENT_h
#define __RTEMS_EVENT_h

#ifdef __cplusplus
extern "C" {
#endif

#include <rtems/score/object.h>
#include <rtems/rtems/types.h>
#include <rtems/rtems/options.h>
#include <rtems/score/thread.h>
#include <rtems/score/watchdog.h>
#include <rtems/rtems/eventset.h>

/*
 *  This constant is passed as the event_in to the
 *  rtems_event_receive directive to determine which events are pending.
 */

#define EVENT_CURRENT  0

/*
 *  The following enumerated types indicate what happened while the event
 *  manager was in the synchronization window.
 */

typedef enum {
  EVENT_SYNC_SYNCHRONIZED,
  EVENT_SYNC_NOTHING_HAPPENED,
  EVENT_SYNC_TIMEOUT,
  EVENT_SYNC_SATISFIED
}  Event_Sync_states;

/*
 *  Event_Manager_initialization
 *
 *  DESCRIPTION:
 *
 *  This routine performs the initialization necessary for this manager.
 */
 
void _Event_Manager_initialization( void );

/*
 *  rtems_event_send
 *
 *  DESCRIPTION:
 *
 *  This routine implements the rtems_event_send directive.  It sends
 *  event_in to the task specified by ID.  If the task is blocked
 *  waiting to receive events and the posting of event_in satisfies
 *  the task's event condition, then it is unblocked.
 */

rtems_status_code rtems_event_send (
  Objects_Id         id,
  rtems_event_set event_in
);

/*
 *  rtems_event_receive
 *
 *  DESCRIPTION:
 *
 *  This routine implements the rtems_event_receive directive.  This
 *  directive is invoked when the calling task wishes to receive
 *  the event_in event condition.  One of the fields in the option_set
 *  parameter determines whether the receive request is satisfied if
 *  any or all of the events are pending.   If the event condition
 *  is not satisfied immediately, then the task may block with an
 *  optional timeout of TICKS clock ticks or return immediately.
 *  This determination is based on another field in the option_set
 *  parameter.  This directive returns the events received in the
 *  event_out parameter.
 */

rtems_status_code rtems_event_receive (
  rtems_event_set  event_in,
  rtems_option     option_set,
  rtems_interval   ticks,
  rtems_event_set *event_out
);

/*
 *  _Event_Seize
 *
 *  DESCRIPTION:
 *
 *  This routine determines if the event condition event_in is
 *  satisfied.  If so or if the no_wait option is enabled in option_set,
 *  then the procedure returns immediately.  If neither of these
 *  conditions is true, then the calling task is blocked with an
 *  optional timeout of ticks clock ticks.
 */

void _Event_Seize (
  rtems_event_set  event_in,
  rtems_option     option_set,
  rtems_interval   ticks,
  rtems_event_set *event_out
);

/*
 *  _Event_Surrender
 *
 *  DESCRIPTION:
 *
 *  This routine determines if the event condition of the_thread
 *  has been satisfied.  If so, it unblocks the_thread.
 */

void _Event_Surrender (
  Thread_Control *the_thread
);

/*
 *  _Event_Timeout
 *
 *  DESCRIPTION:
 *
 *  This routine is invoked when a task's event receive request
 *  has not been satisfied after the specified timeout interval.
 *  The task represented by ID will be unblocked and its status
 *  code will be set in it's control block to indicate that a timeout
 *  has occurred.
 */

void _Event_Timeout (
  Objects_Id  id,
  void       *ignored
);

/*
 *  The following defines the synchronization flag used by the
 *  Event Manager to insure that signals sent to the currently
 *  executing thread are received properly.
 */

RTEMS_EXTERN volatile Event_Sync_states _Event_Sync_state;

#include <rtems/rtems/eventmp.h>
#ifndef __RTEMS_APPLICATION__
#include <rtems/rtems/event.inl>
#endif

#ifdef __cplusplus
}
#endif

#endif
/* end of include file */