source: rtems/doc/user/event.t @ 61389eac

4.104.114.84.95
Last change on this file since 61389eac was 61389eac, checked in by Joel Sherrill <joel.sherrill@…>, on 05/29/97 at 21:53:58

first cut at Ada bindings manual

  • Property mode set to 100644
File size: 12.4 KB
Line 
1@c
2@c  COPYRIGHT (c) 1996.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6
7@ifinfo
8@node Event Manager, Event Manager Introduction, MESSAGE_QUEUE_FLUSH - Flush all messages on a queue, Top
9@end ifinfo
10@chapter Event Manager
11@ifinfo
12@menu
13* Event Manager Introduction::
14* Event Manager Background::
15* Event Manager Operations::
16* Event Manager Directives::
17@end menu
18@end ifinfo
19
20@ifinfo
21@node Event Manager Introduction, Event Manager Background, Event Manager, Event Manager
22@end ifinfo
23@section Introduction
24
25The event manager provides a high performance method
26of intertask communication and synchronization.  The directives
27provided by the event manager are:
28
29@itemize @bullet
30@item @code{event_send} - Send event set to a task
31@item @code{event_receive} - Receive event condition
32@end itemize
33
34@ifinfo
35@node Event Manager Background, Event Sets, Event Manager Introduction, Event Manager
36@end ifinfo
37@section Background
38@ifinfo
39@menu
40* Event Sets::
41* Building an Event Set or Condition::
42* Building an EVENT_RECEIVE Option Set::
43@end menu
44@end ifinfo
45
46@ifinfo
47@node Event Sets, Building an Event Set or Condition, Event Manager Background, Event Manager Background
48@end ifinfo
49@subsection Event Sets
50
51An event flag is used by a task (or ISR) to inform
52another task of the occurrence of a significant situation.
53Thirty-two event flags are associated with each task.  A
54collection of one or more event flags is referred to as an event
55set.  The application developer should remember the following
56key characteristics of event operations when utilizing the event
57manager:
58
59@itemize @bullet
60@item Events provide a simple synchronization facility.
61
62@item Events are aimed at tasks.
63
64@item Tasks can wait on more than one event simultaneously.
65
66@item Events are independent of one another.
67
68@item Events do not hold or transport data.
69
70@item Events are not queued.  In other words, if an event is
71sent more than once before being received, the second and
72subsequent send operations have no effect.
73@end itemize
74
75An event set is posted when it is directed (or sent)
76to a task.  A pending event is an event that has been posted but
77not received.  An event condition is used to specify the events
78which the task desires to receive and the algorithm which will
79be used to determine when the request is satisfied. An event
80condition is satisfied based upon one of two algorithms which
81are selected by the user.  The EVENT_ANY algorithm states that
82an event condition is satisfied when at least a single requested
83event is posted.  The EVENT_ALL algorithm states that an event
84condition is satisfied when every requested event is posted.
85
86@ifinfo
87@node Building an Event Set or Condition, Building an EVENT_RECEIVE Option Set, Event Sets, Event Manager Background
88@end ifinfo
89@subsection Building an Event Set or Condition
90
91An event set or condition is built by a bitwise OR of
92the desired events.  The set of valid events is EVENT_0 through
93EVENT_31.  If an event is not explicitly specified in the set or
94condition, then it is not present.  Events are specifically
95designed to be mutually exclusive, therefore bitwise OR and
96addition operations are equivalent as long as each event appears
97exactly once in the event set list.
98
99For example, when sending the event set consisting of
100EVENT_6, EVENT_15, and EVENT_31, the event parameter to the
101event_send directive should be EVENT_6 | EVENT_15 | EVENT_31.
102
103@ifinfo
104@node Building an EVENT_RECEIVE Option Set, Event Manager Operations, Building an Event Set or Condition, Event Manager Background
105@end ifinfo
106@subsection Building an EVENT_RECEIVE Option Set
107
108In general, an option is built by a bitwise OR of the
109desired option components.  The set of valid options for the
110event_receive directive are listed in the following table:
111
112@itemize @bullet
113@item WAIT - task will wait for event (default)
114@item NO_WAIT - task should not wait
115@item EVENT_ALL - return after all events (default)
116@item EVENT_ANY - return after any events
117@end itemize
118
119Option values are specifically designed to be
120mutually exclusive, therefore bitwise OR and addition operations
121are equivalent as long as each option appears exactly once in
122the component list.  An option listed as a default is not
123required to appear in the option list, although it is a good
124programming practice to specify default options.  If all
125defaults are desired, the option DEFAULT_OPTIONS should be
126specified on this call.
127
128This example demonstrates the option parameter needed
129to poll for all events in a particular event condition to
130arrive.  The option parameter passed to the event_receive
131directive should be either EVENT_ALL | NO_WAIT or NO_WAIT.  The
132option parameter can be set to NO_WAIT because EVENT_ALL is the
133default condition for event_receive.
134
135@ifinfo
136@node Event Manager Operations, Sending an Event Set, Building an EVENT_RECEIVE Option Set, Event Manager
137@end ifinfo
138@section Operations
139@ifinfo
140@menu
141* Sending an Event Set::
142* Receiving an Event Set::
143* Determining the Pending Event Set::
144* Receiving all Pending Events::
145@end menu
146@end ifinfo
147
148@ifinfo
149@node Sending an Event Set, Receiving an Event Set, Event Manager Operations, Event Manager Operations
150@end ifinfo
151@subsection Sending an Event Set
152
153The event_send directive allows a task (or an ISR) to
154direct an event set to a target task.  Based upon the state of
155the target task, one of the following situations applies:
156
157@itemize @bullet
158@item Target Task is Blocked Waiting for Events
159
160@itemize -
161
162@item If the waiting task's input event condition is
163satisfied, then the task is made ready for execution.
164
165@item If the waiting task's input event condition is not
166satisfied, then the event set is posted but left pending and the
167task remains blocked.
168
169@end itemize
170
171@item Target Task is Not Waiting for Events
172
173@itemize -
174@item The event set is posted and left pending.
175@end itemize
176
177@end itemize
178
179@ifinfo
180@node Receiving an Event Set, Determining the Pending Event Set, Sending an Event Set, Event Manager Operations
181@end ifinfo
182@subsection Receiving an Event Set
183
184The event_receive directive is used by tasks to
185accept a specific input event condition.  The task also
186specifies whether the request is satisfied when all requested
187events are available or any single requested event is available.
188If the requested event condition is satisfied by pending
189events, then a successful return code and the satisfying event
190set are returned immediately.  If the condition is not
191satisfied, then one of the following situations applies:
192
193@itemize @bullet
194@item By default, the calling task will wait forever for the
195event condition to be satisfied.
196
197@item Specifying the NO_WAIT option forces an immediate return
198with an error status code.
199
200@item Specifying a timeout limits the period the task will
201wait before returning with an error status code.
202@end itemize
203
204@ifinfo
205@node Determining the Pending Event Set, Receiving all Pending Events, Receiving an Event Set, Event Manager Operations
206@end ifinfo
207@subsection Determining the Pending Event Set
208
209A task can determine the pending event set by calling
210the event_receive directive with a value of PENDING_EVENTS for
211the input event condition.  The pending events are returned to
212the calling task but the event set is left unaltered.
213
214@ifinfo
215@node Receiving all Pending Events, Event Manager Directives, Determining the Pending Event Set, Event Manager Operations
216@end ifinfo
217@subsection Receiving all Pending Events
218
219A task can receive all of the currently pending
220events by calling the event_receive directive with a value of
221ALL_EVENTS for the input event condition and NO_WAIT | EVENT_ANY
222for the option set.  The pending events are returned to the
223calling task and the event set is cleared.  If no events are
224pending then the UNSATISFIED status code will be returned.
225
226@ifinfo
227@node Event Manager Directives, EVENT_SEND - Send event set to a task, Receiving all Pending Events, Event Manager
228@end ifinfo
229@section Directives
230@ifinfo
231@menu
232* EVENT_SEND - Send event set to a task::
233* EVENT_RECEIVE - Receive event condition::
234@end menu
235@end ifinfo
236
237This section details the event manager's directives.
238A subsection is dedicated to each of this manager's directives
239and describes the calling sequence, related constants, usage,
240and status codes.
241
242@page
243@ifinfo
244@node EVENT_SEND - Send event set to a task, EVENT_RECEIVE - Receive event condition, Event Manager Directives, Event Manager Directives
245@end ifinfo
246@subsection EVENT_SEND - Send event set to a task
247
248@subheading CALLING SEQUENCE:
249
250@ifset is-C
251@example
252rtems_status_code rtems_event_send (
253  rtems_id         id,
254  rtems_event_set  event_in
255);
256@end example
257@end ifset
258
259@ifset is-Ada
260@example
261procedure Event_Send (
262   ID       : in     RTEMS.ID;
263   Event_In : in     RTEMS.Event_Set;
264   Result   :    out RTEMS.Status_Codes
265);
266@end example
267@end ifset
268
269@subheading DIRECTIVE STATUS CODES:
270@code{SUCCESSFUL} - event set sent successfully@*
271@code{INVALID_ID} - invalid task id
272
273@subheading DESCRIPTION:
274
275This directive sends an event set, event_in, to the
276task specified by id.  If a blocked task's input event condition
277is satisfied by this directive, then it will be made ready.  If
278its input event condition is not satisfied, then the events
279satisfied are updated and the events not satisfied are left
280pending.  If the task specified by id is not blocked waiting for
281events, then the events sent are left pending.
282
283@subheading NOTES:
284
285Specifying SELF for id results in the event set being
286sent to the calling task.
287
288Identical events sent to a task are not queued.  In
289other words, the second, and subsequent, posting of an event to
290a task before it can perform an event_receive has no effect.
291
292The calling task will be preempted if it has
293preemption enabled and a higher priority task is unblocked as
294the result of this directive.
295
296Sending an event set to a global task which does not
297reside on the local node will generate a request telling the
298remote node to send the event set to the appropriate task.
299
300@page
301@ifinfo
302@node EVENT_RECEIVE - Receive event condition, Signal Manager, EVENT_SEND - Send event set to a task, Event Manager Directives
303@end ifinfo
304@subsection EVENT_RECEIVE - Receive event condition
305
306@subheading CALLING SEQUENCE:
307
308@ifset is-C
309@example
310rtems_status_code rtems_event_receive (
311  rtems_event_set  event_in,
312  rtems_option     option_set,
313  rtems_interval   ticks,
314  rtems_event_set *event_out
315);
316@end example
317@end ifset
318
319@ifset is-Ada
320@example
321procedure Event_Receive (
322   Event_In   : in     RTEMS.Event_Set;
323   Option_Set : in     RTEMS.Option;
324   Ticks      : in     RTEMS.Interval;
325   Event_Out  :    out RTEMS.Event_Set;
326   Result     :    out RTEMS.Status_Codes
327);
328@end example
329@end ifset
330
331@subheading DIRECTIVE STATUS CODES:
332@code{SUCCESSFUL} - event received successfully@*
333@code{UNSATISFIED} - input event not satisfied (NO_WAIT)@*
334@code{TIMEOUT} - timed out waiting for event
335
336@subheading DESCRIPTION:
337
338This directive attempts to receive the event
339condition specified in event_in.  If event_in is set to
340PENDING_EVENTS, then the current pending events are returned in
341event_out and left pending.  The WAIT and NO_WAIT options in the
342option_set parameter are used to specify whether or not the task
343is willing to wait for the event condition to be satisfied.
344EVENT_ANY and EVENT_ALL are used in the option_set parameter are
345used to specify whether a single event or the complete event set
346is necessary to satisfy the event condition.  The event_out
347parameter is returned to the calling task with the value that
348corresponds to the events in event_in that were satisfied.
349
350If pending events satisfy the event condition, then
351event_out is set to the satisfied events and the pending events
352in the event condition are cleared.  If the event condition is
353not satisfied and NO_WAIT is specified, then event_out is set to
354the currently satisfied events.  If the calling task chooses to
355wait, then it will block waiting for the event condition.
356
357If the calling task must wait for the event condition
358to be satisfied, then the timeout parameter is used to specify
359the maximum interval to wait.  If it is set to NO_TIMEOUT, then
360the calling task will wait forever.
361
362@subheading NOTES:
363
364This directive only affects the events specified in
365event_in.  Any pending events that do not correspond to any of
366the events specified in event_in will be left pending.
367
368The following event receive option constants are defined by
369RTEMS:
370
371@itemize @bullet
372@item WAIT      task will wait for event (default)
373@item NO_WAIT   task should not wait
374@item EVENT_ALL         return after all events (default)
375@item EVENT_ANY         return after any events
376@end itemize
377
Note: See TracBrowser for help on using the repository browser.