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