source: rtems-docs/c_user/message_manager.rst @ 9aafb39

4.115
Last change on this file since 9aafb39 was 489740f, checked in by Chris Johns <chrisj@…>, on 05/20/16 at 02:47:09

Set SPDX License Identifier in each source file.

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