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