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 | |
---|
25 | The event manager provides a high performance method |
---|
26 | of intertask communication and synchronization. The directives |
---|
27 | provided 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 | |
---|
51 | An event flag is used by a task (or ISR) to inform |
---|
52 | another task of the occurrence of a significant situation. |
---|
53 | Thirty-two event flags are associated with each task. A |
---|
54 | collection of one or more event flags is referred to as an event |
---|
55 | set. The application developer should remember the following |
---|
56 | key characteristics of event operations when utilizing the event |
---|
57 | manager: |
---|
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 |
---|
71 | sent more than once before being received, the second and |
---|
72 | subsequent send operations have no effect. |
---|
73 | @end itemize |
---|
74 | |
---|
75 | An event set is posted when it is directed (or sent) |
---|
76 | to a task. A pending event is an event that has been posted but |
---|
77 | not received. An event condition is used to specify the events |
---|
78 | which the task desires to receive and the algorithm which will |
---|
79 | be used to determine when the request is satisfied. An event |
---|
80 | condition is satisfied based upon one of two algorithms which |
---|
81 | are selected by the user. The EVENT_ANY algorithm states that |
---|
82 | an event condition is satisfied when at least a single requested |
---|
83 | event is posted. The EVENT_ALL algorithm states that an event |
---|
84 | condition 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 | |
---|
91 | An event set or condition is built by a bitwise OR of |
---|
92 | the desired events. The set of valid events is EVENT_0 through |
---|
93 | EVENT_31. If an event is not explicitly specified in the set or |
---|
94 | condition, then it is not present. Events are specifically |
---|
95 | designed to be mutually exclusive, therefore bitwise OR and |
---|
96 | addition operations are equivalent as long as each event appears |
---|
97 | exactly once in the event set list. |
---|
98 | |
---|
99 | For example, when sending the event set consisting of |
---|
100 | EVENT_6, EVENT_15, and EVENT_31, the event parameter to the |
---|
101 | event_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 | |
---|
108 | In general, an option is built by a bitwise OR of the |
---|
109 | desired option components. The set of valid options for the |
---|
110 | event_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 | |
---|
119 | Option values are specifically designed to be |
---|
120 | mutually exclusive, therefore bitwise OR and addition operations |
---|
121 | are equivalent as long as each option appears exactly once in |
---|
122 | the component list. An option listed as a default is not |
---|
123 | required to appear in the option list, although it is a good |
---|
124 | programming practice to specify default options. If all |
---|
125 | defaults are desired, the option DEFAULT_OPTIONS should be |
---|
126 | specified on this call. |
---|
127 | |
---|
128 | This example demonstrates the option parameter needed |
---|
129 | to poll for all events in a particular event condition to |
---|
130 | arrive. The option parameter passed to the event_receive |
---|
131 | directive should be either EVENT_ALL | NO_WAIT or NO_WAIT. The |
---|
132 | option parameter can be set to NO_WAIT because EVENT_ALL is the |
---|
133 | default 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 | |
---|
153 | The event_send directive allows a task (or an ISR) to |
---|
154 | direct an event set to a target task. Based upon the state of |
---|
155 | the 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 |
---|
163 | satisfied, then the task is made ready for execution. |
---|
164 | |
---|
165 | @item If the waiting task's input event condition is not |
---|
166 | satisfied, then the event set is posted but left pending and the |
---|
167 | task 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 | |
---|
184 | The event_receive directive is used by tasks to |
---|
185 | accept a specific input event condition. The task also |
---|
186 | specifies whether the request is satisfied when all requested |
---|
187 | events are available or any single requested event is available. |
---|
188 | If the requested event condition is satisfied by pending |
---|
189 | events, then a successful return code and the satisfying event |
---|
190 | set are returned immediately. If the condition is not |
---|
191 | satisfied, then one of the following situations applies: |
---|
192 | |
---|
193 | @itemize @bullet |
---|
194 | @item By default, the calling task will wait forever for the |
---|
195 | event condition to be satisfied. |
---|
196 | |
---|
197 | @item Specifying the NO_WAIT option forces an immediate return |
---|
198 | with an error status code. |
---|
199 | |
---|
200 | @item Specifying a timeout limits the period the task will |
---|
201 | wait 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 | |
---|
209 | A task can determine the pending event set by calling |
---|
210 | the event_receive directive with a value of PENDING_EVENTS for |
---|
211 | the input event condition. The pending events are returned to |
---|
212 | the 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 | |
---|
219 | A task can receive all of the currently pending |
---|
220 | events by calling the event_receive directive with a value of |
---|
221 | ALL_EVENTS for the input event condition and NO_WAIT | EVENT_ANY |
---|
222 | for the option set. The pending events are returned to the |
---|
223 | calling task and the event set is cleared. If no events are |
---|
224 | pending 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 | |
---|
237 | This section details the event manager's directives. |
---|
238 | A subsection is dedicated to each of this manager's directives |
---|
239 | and describes the calling sequence, related constants, usage, |
---|
240 | and 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 |
---|
252 | rtems_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 |
---|
261 | procedure 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 | |
---|
275 | This directive sends an event set, event_in, to the |
---|
276 | task specified by id. If a blocked task's input event condition |
---|
277 | is satisfied by this directive, then it will be made ready. If |
---|
278 | its input event condition is not satisfied, then the events |
---|
279 | satisfied are updated and the events not satisfied are left |
---|
280 | pending. If the task specified by id is not blocked waiting for |
---|
281 | events, then the events sent are left pending. |
---|
282 | |
---|
283 | @subheading NOTES: |
---|
284 | |
---|
285 | Specifying SELF for id results in the event set being |
---|
286 | sent to the calling task. |
---|
287 | |
---|
288 | Identical events sent to a task are not queued. In |
---|
289 | other words, the second, and subsequent, posting of an event to |
---|
290 | a task before it can perform an event_receive has no effect. |
---|
291 | |
---|
292 | The calling task will be preempted if it has |
---|
293 | preemption enabled and a higher priority task is unblocked as |
---|
294 | the result of this directive. |
---|
295 | |
---|
296 | Sending an event set to a global task which does not |
---|
297 | reside on the local node will generate a request telling the |
---|
298 | remote 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 |
---|
310 | rtems_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 |
---|
321 | procedure 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 | |
---|
338 | This directive attempts to receive the event |
---|
339 | condition specified in event_in. If event_in is set to |
---|
340 | PENDING_EVENTS, then the current pending events are returned in |
---|
341 | event_out and left pending. The WAIT and NO_WAIT options in the |
---|
342 | option_set parameter are used to specify whether or not the task |
---|
343 | is willing to wait for the event condition to be satisfied. |
---|
344 | EVENT_ANY and EVENT_ALL are used in the option_set parameter are |
---|
345 | used to specify whether a single event or the complete event set |
---|
346 | is necessary to satisfy the event condition. The event_out |
---|
347 | parameter is returned to the calling task with the value that |
---|
348 | corresponds to the events in event_in that were satisfied. |
---|
349 | |
---|
350 | If pending events satisfy the event condition, then |
---|
351 | event_out is set to the satisfied events and the pending events |
---|
352 | in the event condition are cleared. If the event condition is |
---|
353 | not satisfied and NO_WAIT is specified, then event_out is set to |
---|
354 | the currently satisfied events. If the calling task chooses to |
---|
355 | wait, then it will block waiting for the event condition. |
---|
356 | |
---|
357 | If the calling task must wait for the event condition |
---|
358 | to be satisfied, then the timeout parameter is used to specify |
---|
359 | the maximum interval to wait. If it is set to NO_TIMEOUT, then |
---|
360 | the calling task will wait forever. |
---|
361 | |
---|
362 | @subheading NOTES: |
---|
363 | |
---|
364 | This directive only affects the events specified in |
---|
365 | event_in. Any pending events that do not correspond to any of |
---|
366 | the events specified in event_in will be left pending. |
---|
367 | |
---|
368 | The following event receive option constants are defined by |
---|
369 | RTEMS: |
---|
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 | |
---|