1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-2002. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Message Manager |
---|
10 | |
---|
11 | @cindex messages |
---|
12 | @cindex message queues |
---|
13 | |
---|
14 | @section Introduction |
---|
15 | |
---|
16 | The message manager provides communication and |
---|
17 | synchronization capabilities using RTEMS message queues. The |
---|
18 | directives provided by the message manager are: |
---|
19 | |
---|
20 | @itemize @bullet |
---|
21 | @item @code{@value{DIRPREFIX}message_queue_create} - Create a queue |
---|
22 | @item @code{@value{DIRPREFIX}message_queue_ident} - Get ID of a queue |
---|
23 | @item @code{@value{DIRPREFIX}message_queue_delete} - Delete a queue |
---|
24 | @item @code{@value{DIRPREFIX}message_queue_send} - Put message at rear of a queue |
---|
25 | @item @code{@value{DIRPREFIX}message_queue_urgent} - Put message at front of a queue |
---|
26 | @item @code{@value{DIRPREFIX}message_queue_broadcast} - Broadcast N messages to a queue |
---|
27 | @item @code{@value{DIRPREFIX}message_queue_receive} - Receive message from a queue |
---|
28 | @item @code{@value{DIRPREFIX}message_queue_get_number_pending} - Get number of messages pending on a queue |
---|
29 | @item @code{@value{DIRPREFIX}message_queue_flush} - Flush all messages on a queue |
---|
30 | @end itemize |
---|
31 | |
---|
32 | @section Background |
---|
33 | |
---|
34 | @subsection Messages |
---|
35 | |
---|
36 | A message is a variable length buffer where |
---|
37 | information can be stored to support communication. The length |
---|
38 | of the message and the information stored in that message are |
---|
39 | user-defined and can be actual data, pointer(s), or empty. |
---|
40 | |
---|
41 | @subsection Message Queues |
---|
42 | |
---|
43 | A message queue permits the passing of messages among |
---|
44 | tasks and ISRs. Message queues can contain a variable number of |
---|
45 | messages. Normally messages are sent to and received from the |
---|
46 | queue in FIFO order using the @code{@value{DIRPREFIX}message_queue_send} |
---|
47 | directive. However, the @code{@value{DIRPREFIX}message_queue_urgent} |
---|
48 | directive can be used to place |
---|
49 | messages at the head of a queue in LIFO order. |
---|
50 | |
---|
51 | Synchronization can be accomplished when a task can |
---|
52 | wait for a message to arrive at a queue. Also, a task may poll |
---|
53 | a queue for the arrival of a message. |
---|
54 | |
---|
55 | The maximum length message which can be sent is set |
---|
56 | on a per message queue basis. |
---|
57 | |
---|
58 | @subsection Building a Message Queue Attribute Set |
---|
59 | |
---|
60 | @cindex message queue attributes |
---|
61 | |
---|
62 | In general, an attribute set is built by a bitwise OR |
---|
63 | of the desired attribute components. The set of valid message |
---|
64 | queue attributes is provided in the following table: |
---|
65 | |
---|
66 | @itemize @bullet |
---|
67 | @item @code{@value{RPREFIX}FIFO} - tasks wait by FIFO (default) |
---|
68 | @item @code{@value{RPREFIX}PRIORITY} - tasks wait by priority |
---|
69 | @item @code{@value{RPREFIX}LOCAL} - local message queue (default) |
---|
70 | @item @code{@value{RPREFIX}GLOBAL} - global message queue |
---|
71 | @end itemize |
---|
72 | |
---|
73 | |
---|
74 | An attribute listed as a default is not required to |
---|
75 | appear in the attribute list, although it is a good programming |
---|
76 | practice to specify default attributes. If all defaults are |
---|
77 | desired, the attribute @code{@value{RPREFIX}DEFAULT_ATTRIBUTES} |
---|
78 | should be specified on this call. |
---|
79 | |
---|
80 | This example demonstrates the attribute_set parameter |
---|
81 | needed to create a local message queue with the task priority |
---|
82 | waiting queue discipline. The attribute_set parameter to the |
---|
83 | @code{@value{DIRPREFIX}message_queue_create} directive could be either |
---|
84 | @code{@value{RPREFIX}PRIORITY} or |
---|
85 | @code{@value{RPREFIX}LOCAL @value{OR} @value{RPREFIX}PRIORITY}. |
---|
86 | The attribute_set parameter can be set to @code{@value{RPREFIX}PRIORITY} |
---|
87 | because @code{@value{RPREFIX}LOCAL} is the default for all created |
---|
88 | message queues. If a similar message queue were to be known globally, then the |
---|
89 | attribute_set parameter would be |
---|
90 | @code{@value{RPREFIX}GLOBAL @value{OR} @value{RPREFIX}PRIORITY}. |
---|
91 | |
---|
92 | @subsection Building a MESSAGE_QUEUE_RECEIVE Option Set |
---|
93 | |
---|
94 | In general, an option is built by a bitwise OR of the |
---|
95 | desired option components. The set of valid options for the |
---|
96 | @code{@value{DIRPREFIX}message_queue_receive} directive are |
---|
97 | listed in the following table: |
---|
98 | |
---|
99 | @itemize @bullet |
---|
100 | @item @code{@value{RPREFIX}WAIT} - task will wait for a message (default) |
---|
101 | @item @code{@value{RPREFIX}NO_WAIT} - task should not wait |
---|
102 | @end itemize |
---|
103 | |
---|
104 | An option listed as a default is not required to |
---|
105 | appear in the option OR list, although it is a good programming |
---|
106 | practice to specify default options. If all defaults are |
---|
107 | desired, the option @code{@value{RPREFIX}DEFAULT_OPTIONS} should |
---|
108 | be specified on this call. |
---|
109 | |
---|
110 | This example demonstrates the option parameter needed |
---|
111 | to poll for a message to arrive. The option parameter passed to |
---|
112 | the @code{@value{DIRPREFIX}message_queue_receive} directive should |
---|
113 | be @code{@value{RPREFIX}NO_WAIT}. |
---|
114 | |
---|
115 | @section Operations |
---|
116 | |
---|
117 | @subsection Creating a Message Queue |
---|
118 | |
---|
119 | The @code{@value{DIRPREFIX}message_queue_create} directive creates a message |
---|
120 | queue with the user-defined name. The user specifies the |
---|
121 | maximum message size and maximum number of messages which can be |
---|
122 | placed in the message queue at one time. The user may select |
---|
123 | FIFO or task priority as the method for placing waiting tasks in |
---|
124 | the task wait queue. RTEMS allocates a Queue Control Block |
---|
125 | (QCB) from the QCB free list to maintain the newly created queue |
---|
126 | as well as memory for the message buffer pool associated with |
---|
127 | this message queue. RTEMS also generates a message queue ID |
---|
128 | which is returned to the calling task. |
---|
129 | |
---|
130 | For GLOBAL message queues, the maximum message size |
---|
131 | is effectively limited to the longest message which the MPCI is |
---|
132 | capable of transmitting. |
---|
133 | |
---|
134 | @subsection Obtaining Message Queue IDs |
---|
135 | |
---|
136 | When a message queue is created, RTEMS generates a |
---|
137 | unique message queue ID. The message queue ID may be obtained |
---|
138 | by either of two methods. First, as the result of an invocation |
---|
139 | of the @code{@value{DIRPREFIX}message_queue_create} directive, the |
---|
140 | queue ID is stored in a user provided location. Second, the queue |
---|
141 | ID may be obtained later using the @code{@value{DIRPREFIX}message_queue_ident} |
---|
142 | directive. The queue ID is used by other message manager |
---|
143 | directives to access this message queue. |
---|
144 | |
---|
145 | @subsection Receiving a Message |
---|
146 | |
---|
147 | The @code{@value{DIRPREFIX}message_queue_receive} directive attempts to |
---|
148 | retrieve a message from the specified message queue. If at |
---|
149 | least one message is in the queue, then the message is removed |
---|
150 | from the queue, copied to the caller's message buffer, and |
---|
151 | returned immediately along with the length of the message. When |
---|
152 | messages are unavailable, one of the following situations |
---|
153 | applies: |
---|
154 | |
---|
155 | @itemize @bullet |
---|
156 | @item By default, the calling task will wait forever for the |
---|
157 | message to arrive. |
---|
158 | |
---|
159 | @item Specifying the @code{@value{RPREFIX}NO_WAIT} option forces an immediate return |
---|
160 | with an error status code. |
---|
161 | |
---|
162 | @item Specifying a timeout limits the period the task will |
---|
163 | wait before returning with an error status. |
---|
164 | @end itemize |
---|
165 | |
---|
166 | If the task waits for a message, then it is placed in |
---|
167 | the message queue's task wait queue in either FIFO or task |
---|
168 | priority order. All tasks waiting on a message queue are |
---|
169 | returned an error code when the message queue is deleted. |
---|
170 | |
---|
171 | @subsection Sending a Message |
---|
172 | |
---|
173 | Messages can be sent to a queue with the |
---|
174 | @code{@value{DIRPREFIX}message_queue_send} and |
---|
175 | @code{@value{DIRPREFIX}message_queue_urgent} directives. These |
---|
176 | directives work identically when tasks are waiting to receive a |
---|
177 | message. A task is removed from the task waiting queue, |
---|
178 | unblocked, and the message is copied to a waiting task's |
---|
179 | message buffer. |
---|
180 | |
---|
181 | When no tasks are waiting at the queue, |
---|
182 | @code{@value{DIRPREFIX}message_queue_send} places the |
---|
183 | message at the rear of the message queue, while |
---|
184 | @code{@value{DIRPREFIX}message_queue_urgent} places the message at the |
---|
185 | front of the queue. The message is copied to a message buffer |
---|
186 | from this message queue's buffer pool and then placed in the |
---|
187 | message queue. Neither directive can successfully send a |
---|
188 | message to a message queue which has a full queue of pending |
---|
189 | messages. |
---|
190 | |
---|
191 | @subsection Broadcasting a Message |
---|
192 | |
---|
193 | The @code{@value{DIRPREFIX}message_queue_broadcast} directive sends the same |
---|
194 | message to every task waiting on the specified message queue as |
---|
195 | an atomic operation. The message is copied to each waiting |
---|
196 | task's message buffer and each task is unblocked. The number of |
---|
197 | tasks which were unblocked is returned to the caller. |
---|
198 | |
---|
199 | @subsection Deleting a Message Queue |
---|
200 | |
---|
201 | The @code{@value{DIRPREFIX}message_queue_delete} directive removes a message |
---|
202 | queue from the system and frees its control block as well as the |
---|
203 | memory associated with this message queue's message buffer pool. |
---|
204 | A message queue can be deleted by any local task that knows the |
---|
205 | message queue's ID. As a result of this directive, all tasks |
---|
206 | blocked waiting to receive a message from the message queue will |
---|
207 | be readied and returned a status code which indicates that the |
---|
208 | message queue was deleted. Any subsequent references to the |
---|
209 | message queue's name and ID are invalid. Any messages waiting |
---|
210 | at the message queue are also deleted and deallocated. |
---|
211 | |
---|
212 | @section Directives |
---|
213 | |
---|
214 | This section details the message manager's |
---|
215 | directives. A subsection is dedicated to each of this manager's |
---|
216 | directives and describes the calling sequence, related |
---|
217 | constants, usage, and status codes. |
---|
218 | |
---|
219 | @c |
---|
220 | @c |
---|
221 | @c |
---|
222 | @page |
---|
223 | @subsection MESSAGE_QUEUE_CREATE - Create a queue |
---|
224 | |
---|
225 | @cindex create a message queue |
---|
226 | |
---|
227 | @subheading CALLING SEQUENCE: |
---|
228 | |
---|
229 | @ifset is-C |
---|
230 | @findex rtems_message_queue_create |
---|
231 | @example |
---|
232 | rtems_status_code rtems_message_queue_create( |
---|
233 | rtems_name name, |
---|
234 | uint32_t count, |
---|
235 | uint32_t max_message_size, |
---|
236 | rtems_attribute attribute_set, |
---|
237 | rtems_id *id |
---|
238 | ); |
---|
239 | @end example |
---|
240 | @end ifset |
---|
241 | |
---|
242 | @ifset is-Ada |
---|
243 | @example |
---|
244 | procedure Message_Queue_Create ( |
---|
245 | Name : in RTEMS.Name; |
---|
246 | Count : in RTEMS.Unsigned32; |
---|
247 | Max_Message_Size : in RTEMS.Unsigned32; |
---|
248 | Attribute_Set : in RTEMS.Attribute; |
---|
249 | ID : out RTEMS.ID; |
---|
250 | Result : out RTEMS.Status_Codes |
---|
251 | ); |
---|
252 | @end example |
---|
253 | @end ifset |
---|
254 | |
---|
255 | @subheading DIRECTIVE STATUS CODES: |
---|
256 | @code{@value{RPREFIX}SUCCESSFUL} - queue created successfully@* |
---|
257 | @code{@value{RPREFIX}INVALID_NAME} - invalid task name@* |
---|
258 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{id} is NULL@* |
---|
259 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid message count@* |
---|
260 | @code{@value{RPREFIX}INVALID_SIZE} - invalid message size@* |
---|
261 | @code{@value{RPREFIX}TOO_MANY} - too many queues created@* |
---|
262 | @code{@value{RPREFIX}UNSATISFIED} - unable to allocate message buffers@* |
---|
263 | @code{@value{RPREFIX}MP_NOT_CONFIGURED} - multiprocessing not configured@* |
---|
264 | @code{@value{RPREFIX}TOO_MANY} - too many global objects |
---|
265 | |
---|
266 | @subheading DESCRIPTION: |
---|
267 | |
---|
268 | This directive creates a message queue which resides |
---|
269 | on the local node with the user-defined name specified in name. |
---|
270 | For control and maintenance of the queue, RTEMS allocates and |
---|
271 | initializes a QCB. Memory is allocated from the RTEMS Workspace |
---|
272 | for the specified count of messages, each of max_message_size |
---|
273 | bytes in length. The RTEMS-assigned queue id, returned in id, |
---|
274 | is used to access the message queue. |
---|
275 | |
---|
276 | Specifying @code{@value{RPREFIX}PRIORITY} in attribute_set causes tasks |
---|
277 | waiting for a message to be serviced according to task priority. |
---|
278 | When @code{@value{RPREFIX}FIFO} is specified, waiting tasks are serviced |
---|
279 | in First In-First Out order. |
---|
280 | |
---|
281 | @subheading NOTES: |
---|
282 | |
---|
283 | This directive will not cause the calling task to be |
---|
284 | preempted. |
---|
285 | |
---|
286 | The following message queue attribute constants are |
---|
287 | defined by RTEMS: |
---|
288 | |
---|
289 | @itemize @bullet |
---|
290 | @item @code{@value{RPREFIX}FIFO} - tasks wait by FIFO (default) |
---|
291 | @item @code{@value{RPREFIX}PRIORITY} - tasks wait by priority |
---|
292 | @item @code{@value{RPREFIX}LOCAL} - local message queue (default) |
---|
293 | @item @code{@value{RPREFIX}GLOBAL} - global message queue |
---|
294 | @end itemize |
---|
295 | |
---|
296 | Message queues should not be made global unless |
---|
297 | remote tasks must interact with the created message queue. This |
---|
298 | is to avoid the system overhead incurred by the creation of a |
---|
299 | global message queue. When a global message queue is created, |
---|
300 | the message queue's name and id must be transmitted to every |
---|
301 | node in the system for insertion in the local copy of the global |
---|
302 | object table. |
---|
303 | |
---|
304 | For GLOBAL message queues, the maximum message size |
---|
305 | is effectively limited to the longest message which the MPCI is |
---|
306 | capable of transmitting. |
---|
307 | |
---|
308 | The total number of global objects, including message |
---|
309 | queues, is limited by the maximum_global_objects field in the |
---|
310 | configuration table. |
---|
311 | |
---|
312 | @c |
---|
313 | @c |
---|
314 | @c |
---|
315 | @page |
---|
316 | @subsection MESSAGE_QUEUE_IDENT - Get ID of a queue |
---|
317 | |
---|
318 | @cindex get ID of a message queue |
---|
319 | |
---|
320 | @subheading CALLING SEQUENCE: |
---|
321 | |
---|
322 | @ifset is-C |
---|
323 | @findex rtems_message_queue_ident |
---|
324 | @example |
---|
325 | rtems_status_code rtems_message_queue_ident( |
---|
326 | rtems_name name, |
---|
327 | uint32_t node, |
---|
328 | rtems_id *id |
---|
329 | ); |
---|
330 | @end example |
---|
331 | @end ifset |
---|
332 | |
---|
333 | @ifset is-Ada |
---|
334 | @example |
---|
335 | procedure Message_Queue_Ident ( |
---|
336 | Name : in RTEMS.Name; |
---|
337 | Node : in RTEMS.Unsigned32; |
---|
338 | ID : out RTEMS.ID; |
---|
339 | Result : out RTEMS.Status_Codes |
---|
340 | ); |
---|
341 | @end example |
---|
342 | @end ifset |
---|
343 | |
---|
344 | @subheading DIRECTIVE STATUS CODES: |
---|
345 | @code{@value{RPREFIX}SUCCESSFUL} - queue identified successfully@* |
---|
346 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{id} is NULL@* |
---|
347 | @code{@value{RPREFIX}INVALID_NAME} - queue name not found@* |
---|
348 | @code{@value{RPREFIX}INVALID_NODE} - invalid node id |
---|
349 | |
---|
350 | @subheading DESCRIPTION: |
---|
351 | |
---|
352 | This directive obtains the queue id associated with |
---|
353 | the queue name specified in name. If the queue name is not |
---|
354 | unique, then the queue id will match one of the queues with that |
---|
355 | name. However, this queue id is not guaranteed to correspond to |
---|
356 | the desired queue. The queue id is used with other message |
---|
357 | related directives to access the message queue. |
---|
358 | |
---|
359 | @subheading NOTES: |
---|
360 | |
---|
361 | This directive will not cause the running task to be |
---|
362 | preempted. |
---|
363 | |
---|
364 | If node is @code{@value{RPREFIX}SEARCH_ALL_NODES}, all nodes are searched |
---|
365 | with the local node being searched first. All other nodes are |
---|
366 | searched with the lowest numbered node searched first. |
---|
367 | |
---|
368 | If node is a valid node number which does not |
---|
369 | represent the local node, then only the message queues exported |
---|
370 | by the designated node are searched. |
---|
371 | |
---|
372 | This directive does not generate activity on remote |
---|
373 | nodes. It accesses only the local copy of the global object |
---|
374 | table. |
---|
375 | |
---|
376 | @c |
---|
377 | @c |
---|
378 | @c |
---|
379 | @page |
---|
380 | @subsection MESSAGE_QUEUE_DELETE - Delete a queue |
---|
381 | |
---|
382 | @cindex delete a message queue |
---|
383 | |
---|
384 | @subheading CALLING SEQUENCE: |
---|
385 | |
---|
386 | @ifset is-C |
---|
387 | @findex rtems_message_queue_delete |
---|
388 | @example |
---|
389 | rtems_status_code rtems_message_queue_delete( |
---|
390 | rtems_id id |
---|
391 | ); |
---|
392 | @end example |
---|
393 | @end ifset |
---|
394 | |
---|
395 | @ifset is-Ada |
---|
396 | @example |
---|
397 | procedure Message_Queue_Delete ( |
---|
398 | ID : in RTEMS.ID; |
---|
399 | Result : out RTEMS.Status_Codes |
---|
400 | ); |
---|
401 | @end example |
---|
402 | @end ifset |
---|
403 | |
---|
404 | @subheading DIRECTIVE STATUS CODES: |
---|
405 | @code{@value{RPREFIX}SUCCESSFUL} - queue deleted successfully@* |
---|
406 | @code{@value{RPREFIX}INVALID_ID} - invalid queue id@* |
---|
407 | @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - cannot delete remote queue |
---|
408 | |
---|
409 | @subheading DESCRIPTION: |
---|
410 | |
---|
411 | This directive deletes the message queue specified by |
---|
412 | id. As a result of this directive, all tasks blocked waiting to |
---|
413 | receive a message from this queue will be readied and returned a |
---|
414 | status code which indicates that the message queue was deleted. |
---|
415 | If no tasks are waiting, but the queue contains messages, then |
---|
416 | RTEMS returns these message buffers back to the system message |
---|
417 | buffer pool. The QCB for this queue as well as the memory for |
---|
418 | the message buffers is reclaimed by RTEMS. |
---|
419 | |
---|
420 | @subheading NOTES: |
---|
421 | |
---|
422 | The calling task will be preempted if its preemption |
---|
423 | mode is enabled and one or more local tasks with a higher |
---|
424 | priority than the calling task are waiting on the deleted queue. |
---|
425 | The calling task will NOT be preempted if the tasks that are |
---|
426 | waiting are remote tasks. |
---|
427 | |
---|
428 | The calling task does not have to be the task that |
---|
429 | created the queue, although the task and queue must reside on |
---|
430 | the same node. |
---|
431 | |
---|
432 | When the queue is deleted, any messages in the queue |
---|
433 | are returned to the free message buffer pool. Any information |
---|
434 | stored in those messages is lost. |
---|
435 | |
---|
436 | When a global message queue is deleted, the message |
---|
437 | queue id must be transmitted to every node in the system for |
---|
438 | deletion from the local copy of the global object table. |
---|
439 | |
---|
440 | Proxies, used to represent remote tasks, are |
---|
441 | reclaimed when the message queue is deleted. |
---|
442 | |
---|
443 | @c |
---|
444 | @c |
---|
445 | @c |
---|
446 | @page |
---|
447 | @subsection MESSAGE_QUEUE_SEND - Put message at rear of a queue |
---|
448 | |
---|
449 | @cindex send message to a queue |
---|
450 | |
---|
451 | @subheading CALLING SEQUENCE: |
---|
452 | |
---|
453 | @ifset is-C |
---|
454 | @findex rtems_message_queue_send |
---|
455 | @example |
---|
456 | rtems_status_code rtems_message_queue_send( |
---|
457 | rtems_id id, |
---|
458 | void *buffer, |
---|
459 | size_t size |
---|
460 | ); |
---|
461 | @end example |
---|
462 | @end ifset |
---|
463 | |
---|
464 | @ifset is-Ada |
---|
465 | @example |
---|
466 | procedure Message_Queue_Send ( |
---|
467 | ID : in RTEMS.ID; |
---|
468 | Buffer : in RTEMS.Address; |
---|
469 | Size : in RTEMS.Unsigned32; |
---|
470 | Result : out RTEMS.Status_Codes |
---|
471 | ); |
---|
472 | @end example |
---|
473 | @end ifset |
---|
474 | |
---|
475 | @subheading DIRECTIVE STATUS CODES: |
---|
476 | @code{@value{RPREFIX}SUCCESSFUL} - message sent successfully@* |
---|
477 | @code{@value{RPREFIX}INVALID_ID} - invalid queue id@* |
---|
478 | @code{@value{RPREFIX}INVALID_SIZE} - invalid message size@* |
---|
479 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{buffer} is NULL@* |
---|
480 | @code{@value{RPREFIX}UNSATISFIED} - out of message buffers@* |
---|
481 | @code{@value{RPREFIX}TOO_MANY} - queue's limit has been reached |
---|
482 | |
---|
483 | @subheading DESCRIPTION: |
---|
484 | |
---|
485 | This directive sends the message buffer of size bytes |
---|
486 | in length to the queue specified by id. If a task is waiting at |
---|
487 | the queue, then the message is copied to the waiting task's |
---|
488 | buffer and the task is unblocked. If no tasks are waiting at the |
---|
489 | queue, then the message is copied to a message buffer which is |
---|
490 | obtained from this message queue's message buffer pool. The |
---|
491 | message buffer is then placed at the rear of the queue. |
---|
492 | |
---|
493 | @subheading NOTES: |
---|
494 | |
---|
495 | The calling task will be preempted if it has |
---|
496 | preemption enabled and a higher priority task is unblocked as |
---|
497 | the result of this directive. |
---|
498 | |
---|
499 | Sending a message to a global message queue which |
---|
500 | does not reside on the local node will generate a request to the |
---|
501 | remote node to post the message on the specified message queue. |
---|
502 | |
---|
503 | If the task to be unblocked resides on a different |
---|
504 | node from the message queue, then the message is forwarded to |
---|
505 | the appropriate node, the waiting task is unblocked, and the |
---|
506 | proxy used to represent the task is reclaimed. |
---|
507 | |
---|
508 | @c |
---|
509 | @c |
---|
510 | @c |
---|
511 | @page |
---|
512 | @subsection MESSAGE_QUEUE_URGENT - Put message at front of a queue |
---|
513 | |
---|
514 | @cindex put message at front of queue |
---|
515 | |
---|
516 | @subheading CALLING SEQUENCE: |
---|
517 | |
---|
518 | @ifset is-C |
---|
519 | @findex rtems_message_queue_urgent |
---|
520 | @example |
---|
521 | rtems_status_code rtems_message_queue_urgent( |
---|
522 | rtems_id id, |
---|
523 | void *buffer, |
---|
524 | size_t size |
---|
525 | ); |
---|
526 | @end example |
---|
527 | @end ifset |
---|
528 | |
---|
529 | @ifset is-Ada |
---|
530 | @example |
---|
531 | procedure Message_Queue_Urgent ( |
---|
532 | ID : in RTEMS.ID; |
---|
533 | Buffer : in RTEMS.Address; |
---|
534 | Size : in RTEMS.Unsigned32; |
---|
535 | Result : out RTEMS.Status_Codes |
---|
536 | ); |
---|
537 | @end example |
---|
538 | @end ifset |
---|
539 | |
---|
540 | @subheading DIRECTIVE STATUS CODES: |
---|
541 | @code{@value{RPREFIX}SUCCESSFUL} - message sent successfully@* |
---|
542 | @code{@value{RPREFIX}INVALID_ID} - invalid queue id@* |
---|
543 | @code{@value{RPREFIX}INVALID_SIZE} - invalid message size@* |
---|
544 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{buffer} is NULL@* |
---|
545 | @code{@value{RPREFIX}UNSATISFIED} - out of message buffers@* |
---|
546 | @code{@value{RPREFIX}TOO_MANY} - queue's limit has been reached |
---|
547 | |
---|
548 | @subheading DESCRIPTION: |
---|
549 | |
---|
550 | This directive sends the message buffer of size bytes |
---|
551 | in length to the queue specified by id. If a task is waiting on |
---|
552 | the queue, then the message is copied to the task's buffer and |
---|
553 | the task is unblocked. If no tasks are waiting on the queue, |
---|
554 | then the message is copied to a message buffer which is obtained |
---|
555 | from this message queue's message buffer pool. The message |
---|
556 | buffer is then placed at the front of the queue. |
---|
557 | |
---|
558 | @subheading NOTES: |
---|
559 | |
---|
560 | The calling task will be preempted if it has |
---|
561 | preemption enabled and a higher priority task is unblocked as |
---|
562 | the result of this directive. |
---|
563 | |
---|
564 | Sending a message to a global message queue which |
---|
565 | does not reside on the local node will generate a request |
---|
566 | telling the remote node to post the message on the specified |
---|
567 | message queue. |
---|
568 | |
---|
569 | If the task to be unblocked resides on a different |
---|
570 | node from the message queue, then the message is forwarded to |
---|
571 | the appropriate node, the waiting task is unblocked, and the |
---|
572 | proxy used to represent the task is reclaimed. |
---|
573 | |
---|
574 | @c |
---|
575 | @c |
---|
576 | @c |
---|
577 | @page |
---|
578 | @subsection MESSAGE_QUEUE_BROADCAST - Broadcast N messages to a queue |
---|
579 | |
---|
580 | @cindex broadcast message to a queue |
---|
581 | |
---|
582 | @subheading CALLING SEQUENCE: |
---|
583 | |
---|
584 | @ifset is-C |
---|
585 | @findex rtems_message_queue_broadcast |
---|
586 | @example |
---|
587 | rtems_status_code rtems_message_queue_broadcast( |
---|
588 | rtems_id id, |
---|
589 | void *buffer, |
---|
590 | size_t size, |
---|
591 | uint32_t *count |
---|
592 | ); |
---|
593 | @end example |
---|
594 | @end ifset |
---|
595 | |
---|
596 | @ifset is-Ada |
---|
597 | @example |
---|
598 | procedure Message_Queue_Broadcast ( |
---|
599 | ID : in RTEMS.ID; |
---|
600 | Buffer : in RTEMS.Address; |
---|
601 | Size : in RTEMS.Unsigned32; |
---|
602 | Count : out RTEMS.Unsigned32; |
---|
603 | Result : out RTEMS.Status_Codes |
---|
604 | ); |
---|
605 | @end example |
---|
606 | @end ifset |
---|
607 | |
---|
608 | @subheading DIRECTIVE STATUS CODES: |
---|
609 | @code{@value{RPREFIX}SUCCESSFUL} - message broadcasted successfully@* |
---|
610 | @code{@value{RPREFIX}INVALID_ID} - invalid queue id@* |
---|
611 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{buffer} is NULL@* |
---|
612 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{count} is NULL@* |
---|
613 | @code{@value{RPREFIX}INVALID_SIZE} - invalid message size |
---|
614 | |
---|
615 | @subheading DESCRIPTION: |
---|
616 | |
---|
617 | This directive causes all tasks that are waiting at |
---|
618 | the queue specified by id to be unblocked and sent the message |
---|
619 | contained in buffer. Before a task is unblocked, the message |
---|
620 | buffer of size byes in length is copied to that task's message |
---|
621 | buffer. The number of tasks that were unblocked is returned in |
---|
622 | count. |
---|
623 | |
---|
624 | @subheading NOTES: |
---|
625 | |
---|
626 | The calling task will be preempted if it has |
---|
627 | preemption enabled and a higher priority task is unblocked as |
---|
628 | the result of this directive. |
---|
629 | |
---|
630 | The execution time of this directive is directly |
---|
631 | related to the number of tasks waiting on the message queue, |
---|
632 | although it is more efficient than the equivalent number of |
---|
633 | invocations of @code{@value{DIRPREFIX}message_queue_send}. |
---|
634 | |
---|
635 | Broadcasting a message to a global message queue |
---|
636 | which does not reside on the local node will generate a request |
---|
637 | telling the remote node to broadcast the message to the |
---|
638 | specified message queue. |
---|
639 | |
---|
640 | When a task is unblocked which resides on a different |
---|
641 | node from the message queue, a copy of the message is forwarded |
---|
642 | to the appropriate node, the waiting task is unblocked, and the |
---|
643 | proxy used to represent the task is reclaimed. |
---|
644 | |
---|
645 | @c |
---|
646 | @c |
---|
647 | @c |
---|
648 | @page |
---|
649 | @subsection MESSAGE_QUEUE_RECEIVE - Receive message from a queue |
---|
650 | |
---|
651 | @cindex receive message from a queue |
---|
652 | |
---|
653 | @subheading CALLING SEQUENCE: |
---|
654 | |
---|
655 | @ifset is-C |
---|
656 | @findex rtems_message_queue_receive |
---|
657 | @example |
---|
658 | rtems_status_code rtems_message_queue_receive( |
---|
659 | rtems_id id, |
---|
660 | void *buffer, |
---|
661 | size_t *size, |
---|
662 | uint32_t option_set, |
---|
663 | rtems_interval timeout |
---|
664 | ); |
---|
665 | @end example |
---|
666 | @end ifset |
---|
667 | |
---|
668 | @ifset is-Ada |
---|
669 | @example |
---|
670 | procedure Message_Queue_Receive ( |
---|
671 | ID : in RTEMS.ID; |
---|
672 | Buffer : in RTEMS.Address; |
---|
673 | Option_Set : in RTEMS.Option; |
---|
674 | Timeout : in RTEMS.Interval; |
---|
675 | Size : out RTEMS.Unsigned32; |
---|
676 | Result : out RTEMS.Status_Codes |
---|
677 | ); |
---|
678 | @end example |
---|
679 | @end ifset |
---|
680 | |
---|
681 | @subheading DIRECTIVE STATUS CODES: |
---|
682 | @code{@value{RPREFIX}SUCCESSFUL} - message received successfully@* |
---|
683 | @code{@value{RPREFIX}INVALID_ID} - invalid queue id@* |
---|
684 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{buffer} is NULL@* |
---|
685 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{count} is NULL@* |
---|
686 | @code{@value{RPREFIX}UNSATISFIED} - queue is empty@* |
---|
687 | @code{@value{RPREFIX}TIMEOUT} - timed out waiting for message@* |
---|
688 | @code{@value{RPREFIX}OBJECT_WAS_DELETED} - queue deleted while waiting |
---|
689 | |
---|
690 | @subheading DESCRIPTION: |
---|
691 | |
---|
692 | This directive receives a message from the message |
---|
693 | queue specified in id. The @code{@value{RPREFIX}WAIT} and @code{@value{RPREFIX}NO_WAIT} options of the |
---|
694 | options parameter allow the calling task to specify whether to |
---|
695 | wait for a message to become available or return immediately. |
---|
696 | For either option, if there is at least one message in the |
---|
697 | queue, then it is copied to buffer, size is set to return the |
---|
698 | length of the message in bytes, and this directive returns |
---|
699 | immediately with a successful return code. |
---|
700 | |
---|
701 | If the calling task chooses to return immediately and |
---|
702 | the queue is empty, then a status code indicating this condition |
---|
703 | is returned. If the calling task chooses to wait at the message |
---|
704 | queue and the queue is empty, then the calling task is placed on |
---|
705 | the message wait queue and blocked. If the queue was created |
---|
706 | with the @code{@value{RPREFIX}PRIORITY} option specified, then |
---|
707 | the calling task is inserted into the wait queue according to |
---|
708 | its priority. But, if the queue was created with the |
---|
709 | @code{@value{RPREFIX}FIFO} option specified, then the |
---|
710 | calling task is placed at the rear of the wait queue. |
---|
711 | |
---|
712 | A task choosing to wait at the queue can optionally |
---|
713 | specify a timeout value in the timeout parameter. The timeout |
---|
714 | parameter specifies the maximum interval to wait before the |
---|
715 | calling task desires to be unblocked. If it is set to |
---|
716 | @code{@value{RPREFIX}NO_TIMEOUT}, then the calling task will wait forever. |
---|
717 | |
---|
718 | @subheading NOTES: |
---|
719 | |
---|
720 | The following message receive option constants are |
---|
721 | defined by RTEMS: |
---|
722 | |
---|
723 | @itemize @bullet |
---|
724 | @item @code{@value{RPREFIX}WAIT} - task will wait for a message (default) |
---|
725 | @item @code{@value{RPREFIX}NO_WAIT} - task should not wait |
---|
726 | @end itemize |
---|
727 | |
---|
728 | Receiving a message from a global message queue which |
---|
729 | does not reside on the local node will generate a request to the |
---|
730 | remote node to obtain a message from the specified message |
---|
731 | queue. If no message is available and @code{@value{RPREFIX}WAIT} was specified, then |
---|
732 | the task must be blocked until a message is posted. A proxy is |
---|
733 | allocated on the remote node to represent the task until the |
---|
734 | message is posted. |
---|
735 | |
---|
736 | A clock tick is required to support the timeout functionality of |
---|
737 | this directive. |
---|
738 | |
---|
739 | @c |
---|
740 | @c |
---|
741 | @c |
---|
742 | @page |
---|
743 | @subsection MESSAGE_QUEUE_GET_NUMBER_PENDING - Get number of messages pending on a queue |
---|
744 | |
---|
745 | @cindex get number of pending messages |
---|
746 | |
---|
747 | @subheading CALLING SEQUENCE: |
---|
748 | |
---|
749 | @ifset is-C |
---|
750 | @findex rtems_message_queue_get_number_pending |
---|
751 | @example |
---|
752 | rtems_status_code rtems_message_queue_get_number_pending( |
---|
753 | rtems_id id, |
---|
754 | uint32_t *count |
---|
755 | ); |
---|
756 | @end example |
---|
757 | @end ifset |
---|
758 | |
---|
759 | @ifset is-Ada |
---|
760 | @example |
---|
761 | procedure Message_Queue_Get_Number_Pending ( |
---|
762 | ID : in RTEMS.ID; |
---|
763 | Count : out RTEMS.Unsigned32; |
---|
764 | Result : out RTEMS.Status_Codes |
---|
765 | ); |
---|
766 | @end example |
---|
767 | @end ifset |
---|
768 | |
---|
769 | @subheading DIRECTIVE STATUS CODES: |
---|
770 | @code{@value{RPREFIX}SUCCESSFUL} - number of messages pending returned successfully@* |
---|
771 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{count} is NULL@* |
---|
772 | @code{@value{RPREFIX}INVALID_ID} - invalid queue id |
---|
773 | |
---|
774 | @subheading DESCRIPTION: |
---|
775 | |
---|
776 | This directive returns the number of messages pending on this |
---|
777 | message queue in count. If no messages are present |
---|
778 | on the queue, count is set to zero. |
---|
779 | |
---|
780 | @subheading NOTES: |
---|
781 | |
---|
782 | Getting the number of pending messages on a global message queue which |
---|
783 | does not reside on the local node will generate a request to the |
---|
784 | remote node to actually obtain the pending message count for |
---|
785 | the specified message queue. |
---|
786 | |
---|
787 | |
---|
788 | @c |
---|
789 | @c |
---|
790 | @c |
---|
791 | @page |
---|
792 | @subsection MESSAGE_QUEUE_FLUSH - Flush all messages on a queue |
---|
793 | |
---|
794 | @cindex flush messages on a queue |
---|
795 | |
---|
796 | @subheading CALLING SEQUENCE: |
---|
797 | |
---|
798 | @ifset is-C |
---|
799 | @findex rtems_message_queue_flush |
---|
800 | @example |
---|
801 | rtems_status_code rtems_message_queue_flush( |
---|
802 | rtems_id id, |
---|
803 | uint32_t *count |
---|
804 | ); |
---|
805 | @end example |
---|
806 | @end ifset |
---|
807 | |
---|
808 | @ifset is-Ada |
---|
809 | @example |
---|
810 | procedure Message_Queue_Flush ( |
---|
811 | ID : in RTEMS.ID; |
---|
812 | Count : out RTEMS.Unsigned32; |
---|
813 | Result : out RTEMS.Status_Codes |
---|
814 | ); |
---|
815 | @end example |
---|
816 | @end ifset |
---|
817 | |
---|
818 | @subheading DIRECTIVE STATUS CODES: |
---|
819 | @code{@value{RPREFIX}SUCCESSFUL} - message queue flushed successfully@* |
---|
820 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{count} is NULL@* |
---|
821 | @code{@value{RPREFIX}INVALID_ID} - invalid queue id |
---|
822 | |
---|
823 | @subheading DESCRIPTION: |
---|
824 | |
---|
825 | This directive removes all pending messages from the |
---|
826 | specified queue id. The number of messages removed is returned |
---|
827 | in count. If no messages are present on the queue, count is set |
---|
828 | to zero. |
---|
829 | |
---|
830 | @subheading NOTES: |
---|
831 | |
---|
832 | Flushing all messages on a global message queue which |
---|
833 | does not reside on the local node will generate a request to the |
---|
834 | remote node to actually flush the specified message queue. |
---|
835 | |
---|