source: rtems/doc/user/event.t @ 75e22db

4.104.114.84.95
Last change on this file since 75e22db was 75e22db, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/98 at 16:47:53

Completed sweep adding directive and constant prefixes.

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