source: rtems/doc/user/event.t @ 1e524995

4.104.114.84.95
Last change on this file since 1e524995 was 1e524995, checked in by Joel Sherrill <joel.sherrill@…>, on 02/06/98 at 14:14:30

Updated copyrights

  • Property mode set to 100644
File size: 12.7 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{event_send} - Send event set to a task
33@item @code{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{EVENT_ANY} algorithm states that
84an event condition is satisfied when at least a single requested
85event is posted.  The @code{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{EVENT_0} through
95@code{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{EVENT_6}, @code{EVENT_15}, and @code{EVENT_31},
103the event parameter to the event_send directive should be
104@code{EVENT_6 @value{OR} EVENT_15 @value{OR} EVENT_31}.
105
106@ifinfo
107@node Building an EVENT_RECEIVE Option Set, Event Manager Operations, Building an Event Set or Condition, Event Manager Background
108@end ifinfo
109@subsection Building an EVENT_RECEIVE Option Set
110
111In general, an option is built by a bitwise OR of the
112desired option components.  The set of valid options for the
113event_receive directive are listed in the following table:
114
115@itemize @bullet
116@item @code{WAIT} - task will wait for event (default)
117@item @code{NO_WAIT} - task should not wait
118@item @code{EVENT_ALL} - return after all events (default)
119@item @code{EVENT_ANY} - return after any events
120@end itemize
121
122Option values are specifically designed to be
123mutually exclusive, therefore bitwise OR and addition operations
124are equivalent as long as each option appears exactly once in
125the component list.  An option listed as a default is not
126required to appear in the option list, although it is a good
127programming practice to specify default options.  If all
128defaults are desired, the option @code{DEFAULT_OPTIONS} should be
129specified on this call.
130
131This example demonstrates the option parameter needed
132to poll for all events in a particular event condition to
133arrive.  The option parameter passed to the event_receive
134directive should be either @code{EVENT_ALL @value{OR} NO_WAIT}
135or @code{NO_WAIT}.  The option parameter can be set to
136@code{NO_WAIT} because @code{EVENT_ALL} is the
137default condition for event_receive.
138
139@ifinfo
140@node Event Manager Operations, Sending an Event Set, Building an EVENT_RECEIVE Option Set, Event Manager
141@end ifinfo
142@section Operations
143@ifinfo
144@menu
145* Sending an Event Set::
146* Receiving an Event Set::
147* Determining the Pending Event Set::
148* Receiving all Pending Events::
149@end menu
150@end ifinfo
151
152@ifinfo
153@node Sending an Event Set, Receiving an Event Set, Event Manager Operations, Event Manager Operations
154@end ifinfo
155@subsection Sending an Event Set
156
157The event_send directive allows a task (or an ISR) to
158direct an event set to a target task.  Based upon the state of
159the target task, one of the following situations applies:
160
161@itemize @bullet
162@item Target Task is Blocked Waiting for Events
163
164@itemize -
165
166@item If the waiting task's input event condition is
167satisfied, then the task is made ready for execution.
168
169@item If the waiting task's input event condition is not
170satisfied, then the event set is posted but left pending and the
171task remains blocked.
172
173@end itemize
174
175@item Target Task is Not Waiting for Events
176
177@itemize -
178@item The event set is posted and left pending.
179@end itemize
180
181@end itemize
182
183@ifinfo
184@node Receiving an Event Set, Determining the Pending Event Set, Sending an Event Set, Event Manager Operations
185@end ifinfo
186@subsection Receiving an Event Set
187
188The event_receive directive is used by tasks to
189accept a specific input event condition.  The task also
190specifies whether the request is satisfied when all requested
191events are available or any single requested event is available.
192If the requested event condition is satisfied by pending
193events, then a successful return code and the satisfying event
194set are returned immediately.  If the condition is not
195satisfied, then one of the following situations applies:
196
197@itemize @bullet
198@item By default, the calling task will wait forever for the
199event condition to be satisfied.
200
201@item Specifying the @code{NO_WAIT} option forces an immediate return
202with an error status code.
203
204@item Specifying a timeout limits the period the task will
205wait before returning with an error status code.
206@end itemize
207
208@ifinfo
209@node Determining the Pending Event Set, Receiving all Pending Events, Receiving an Event Set, Event Manager Operations
210@end ifinfo
211@subsection Determining the Pending Event Set
212
213A task can determine the pending event set by calling
214the event_receive directive with a value of PENDING_EVENTS for
215the input event condition.  The pending events are returned to
216the calling task but the event set is left unaltered.
217
218@ifinfo
219@node Receiving all Pending Events, Event Manager Directives, Determining the Pending Event Set, Event Manager Operations
220@end ifinfo
221@subsection Receiving all Pending Events
222
223A task can receive all of the currently pending
224events by calling the event_receive directive with a value of
225@code{ALL_EVENTS} for the input event condition and
226@code{NO_WAIT @value{OR} EVENT_ANY}
227for the option set.  The pending events are returned to the
228calling task and the event set is cleared.  If no events are
229pending then the @code{UNSATISFIED} status code will be returned.
230
231@ifinfo
232@node Event Manager Directives, EVENT_SEND - Send event set to a task, Receiving all Pending Events, Event Manager
233@end ifinfo
234@section Directives
235@ifinfo
236@menu
237* EVENT_SEND - Send event set to a task::
238* EVENT_RECEIVE - Receive event condition::
239@end menu
240@end ifinfo
241
242This section details the event manager's directives.
243A subsection is dedicated to each of this manager's directives
244and describes the calling sequence, related constants, usage,
245and status codes.
246
247@page
248@ifinfo
249@node EVENT_SEND - Send event set to a task, EVENT_RECEIVE - Receive event condition, Event Manager Directives, Event Manager Directives
250@end ifinfo
251@subsection EVENT_SEND - Send event set to a task
252
253@subheading CALLING SEQUENCE:
254
255@ifset is-C
256@example
257rtems_status_code rtems_event_send (
258  rtems_id         id,
259  rtems_event_set  event_in
260);
261@end example
262@end ifset
263
264@ifset is-Ada
265@example
266procedure Event_Send (
267   ID       : in     RTEMS.ID;
268   Event_In : in     RTEMS.Event_Set;
269   Result   :    out RTEMS.Status_Codes
270);
271@end example
272@end ifset
273
274@subheading DIRECTIVE STATUS CODES:
275@code{SUCCESSFUL} - event set sent successfully@*
276@code{INVALID_ID} - invalid task id
277
278@subheading DESCRIPTION:
279
280This directive sends an event set, event_in, to the
281task specified by id.  If a blocked task's input event condition
282is satisfied by this directive, then it will be made ready.  If
283its input event condition is not satisfied, then the events
284satisfied are updated and the events not satisfied are left
285pending.  If the task specified by id is not blocked waiting for
286events, then the events sent are left pending.
287
288@subheading NOTES:
289
290Specifying @code{SELF} for id results in the event set being
291sent to the calling task.
292
293Identical events sent to a task are not queued.  In
294other words, the second, and subsequent, posting of an event to
295a task before it can perform an event_receive has no effect.
296
297The calling task will be preempted if it has
298preemption enabled and a higher priority task is unblocked as
299the result of this directive.
300
301Sending an event set to a global task which does not
302reside on the local node will generate a request telling the
303remote node to send the event set to the appropriate task.
304
305@page
306@ifinfo
307@node EVENT_RECEIVE - Receive event condition, Signal Manager, EVENT_SEND - Send event set to a task, Event Manager Directives
308@end ifinfo
309@subsection EVENT_RECEIVE - Receive event condition
310
311@subheading CALLING SEQUENCE:
312
313@ifset is-C
314@example
315rtems_status_code rtems_event_receive (
316  rtems_event_set  event_in,
317  rtems_option     option_set,
318  rtems_interval   ticks,
319  rtems_event_set *event_out
320);
321@end example
322@end ifset
323
324@ifset is-Ada
325@example
326procedure Event_Receive (
327   Event_In   : in     RTEMS.Event_Set;
328   Option_Set : in     RTEMS.Option;
329   Ticks      : in     RTEMS.Interval;
330   Event_Out  :    out RTEMS.Event_Set;
331   Result     :    out RTEMS.Status_Codes
332);
333@end example
334@end ifset
335
336@subheading DIRECTIVE STATUS CODES:
337@code{SUCCESSFUL} - event received successfully@*
338@code{UNSATISFIED} - input event not satisfied (@code{NO_WAIT})@*
339@code{TIMEOUT} - timed out waiting for event
340
341@subheading DESCRIPTION:
342
343This directive attempts to receive the event
344condition specified in event_in.  If event_in is set to
345@code{PENDING_EVENTS}, then the current pending events are returned in
346event_out and left pending.  The @code{WAIT} and @code{NO_WAIT} options in the
347option_set parameter are used to specify whether or not the task
348is willing to wait for the event condition to be satisfied.
349@code{EVENT_ANY} and @code{EVENT_ALL} are used in the option_set parameter are
350used to specify whether a single event or the complete event set
351is necessary to satisfy the event condition.  The event_out
352parameter is returned to the calling task with the value that
353corresponds to the events in event_in that were satisfied.
354
355If pending events satisfy the event condition, then
356event_out is set to the satisfied events and the pending events
357in the event condition are cleared.  If the event condition is
358not satisfied and @code{NO_WAIT} is specified, then event_out is set to
359the currently satisfied events.  If the calling task chooses to
360wait, then it will block waiting for the event condition.
361
362If the calling task must wait for the event condition
363to be satisfied, then the timeout parameter is used to specify
364the maximum interval to wait.  If it is set to @code{NO_TIMEOUT}, then
365the calling task will wait forever.
366
367@subheading NOTES:
368
369This directive only affects the events specified in
370event_in.  Any pending events that do not correspond to any of
371the events specified in event_in will be left pending.
372
373The following event receive option constants are defined by
374RTEMS:
375
376@itemize @bullet
377@item @code{WAIT}       task will wait for event (default)
378@item @code{NO_WAIT}    task should not wait
379@item @code{EVENT_ALL}  return after all events (default)
380@item @code{EVENT_ANY}  return after any events
381@end itemize
382
383A clock tick is required to support the functionality of this directive.
Note: See TracBrowser for help on using the repository browser.