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