source: rtems/doc/user/msg.t @ a94c5a5d

4.104.114.84.95
Last change on this file since a94c5a5d was a94c5a5d, checked in by Joel Sherrill <joel.sherrill@…>, on 05/31/97 at 15:55:10

Changed bitwise OR's used to build up option and attribute sets
to be correct in either C or Ada.

Added the interrupt disable, enable, flash, and is in progress directives.

changed "97" to "1997"

  • Property mode set to 100644
File size: 27.2 KB
Line 
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
25The message manager provides communication and
26synchronization capabilities using RTEMS message queues.  The
27directives 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
58A message is a variable length buffer where
59information can be stored to support communication.  The length
60of the message and the information stored in that message are
61user-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
68A message queue permits the passing of messages among
69tasks and ISRs.  Message queues can contain a variable number of
70messages.  Normally messages are sent to and received from the
71queue in FIFO order using the message_queue_send directive.
72However, the message_queue_urgent directive can be used to place
73messages at the head of a queue in LIFO order.
74
75Synchronization can be accomplished when a task can
76wait for a message to arrive at a queue.  Also, a task may poll
77a queue for the arrival of a message.
78
79The maximum length message which can be sent is set
80on 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
87In general, an attribute set is built by a bitwise OR
88of the desired attribute components.  The set of valid message
89queue 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
100An attribute listed as a default is not required to
101appear in the attribute list, although it is a good programming
102practice to specify default attributes.  If all defaults are
103desired, the attribute @code{DEFAULT_ATTRIBUTES} should be specified on
104this call.
105
106This example demonstrates the attribute_set parameter
107needed to create a local message queue with the task priority
108waiting queue discipline.  The attribute_set parameter to the
109message_queue_create directive could be either
110@code{PRIORITY} or @code{LOCAL @value{OR} PRIORITY}. 
111The attribute_set parameter can be set to @code{PRIORITY}
112because @code{LOCAL} is the default for all created message queues.  If
113a similar message queue were to be known globally, then the
114attribute_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
121In general, an option is built by a bitwise OR of the
122desired option components.  The set of valid options for the
123message_queue_receive directive are listed in the following
124table:
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
131An option listed as a default is not required to
132appear in the option OR list, although it is a good programming
133practice to specify default options.  If all defaults are
134desired, the option @code{DEFAULT_OPTIONS} should be specified on this
135call.
136
137This example demonstrates the option parameter needed
138to poll for a message to arrive.  The option parameter passed to
139the 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
161The message_queue_create directive creates a message
162queue with the user-defined name.  The user specifies the
163maximum message size and maximum number of messages which can be
164placed in the message queue at one time.  The user may select
165FIFO or task priority as the method for placing waiting tasks in
166the task wait queue.  RTEMS allocates a Queue Control Block
167(QCB) from the QCB free list to maintain the newly created queue
168as well as memory for the message buffer pool associated with
169this message queue.  RTEMS also generates a message queue ID
170which is returned to the calling task.
171
172For GLOBAL message queues, the maximum message size
173is effectively limited to the longest message which the MPCI is
174capable 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
181When a message queue is created, RTEMS generates a
182unique message queue ID.  The message queue ID may be obtained
183by either of two methods.  First, as the result of an invocation
184of the message_queue_create directive, the queue ID is stored in
185a user provided location.  Second, the queue ID may be obtained
186later using the message_queue_ident directive.  The queue ID is
187used by other message manager directives to access this message
188queue.
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
195The message_queue_receive directive attempts to
196retrieve a message from the specified message queue.  If at
197least one message is in the queue, then the message is removed
198from the queue, copied to the caller's message buffer, and
199returned immediately along with the length of the message.  When
200messages are unavailable, one of the following situations
201applies:
202
203@itemize @bullet
204@item By default, the calling task will wait forever for the
205message to arrive.
206
207@item Specifying the @code{NO_WAIT} option forces an immediate return
208with an error status code.
209
210@item Specifying a timeout limits the period the task will
211wait before returning with an error status.
212@end itemize
213
214If the task waits for a message, then it is placed in
215the message queue's task wait queue in either FIFO or task
216priority order.  All tasks waiting on a message queue are
217returned 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
224Messages can be sent to a queue with the
225message_queue_send and message_queue_urgent directives.  These
226directives work identically when tasks are waiting to receive a
227message.  A task is removed from the task waiting queue,
228unblocked,  and the message is copied to a waiting task's
229message buffer.
230
231When no tasks are waiting at the queue,
232message_queue_send places the message at the rear of the message
233queue, while message_queue_urgent places the message at the
234front of the queue.  The message is copied to a message buffer
235from this message queue's buffer pool and then placed in the
236message queue.  Neither directive can successfully send a
237message to a message queue which has a full queue of pending
238messages.
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
245The message_queue_broadcast directive sends the same
246message to every task waiting on the specified message queue as
247an atomic operation.  The message is copied to each waiting
248task's message buffer and each task is unblocked.  The number of
249tasks 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
256The message_queue_delete directive removes a message
257queue from the system and frees its control block as well as the
258memory associated with this message queue's message buffer pool.
259A message queue can be deleted by any local task that knows the
260message queue's ID.  As a result of this directive, all tasks
261blocked waiting to receive a message from the message queue will
262be readied and returned a status code which indicates that the
263message queue was deleted.  Any subsequent references to the
264message queue's name and ID are invalid.  Any messages waiting
265at 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
284This section details the message manager's
285directives.  A subsection is dedicated to each of this manager's
286directives and describes the calling sequence, related
287constants, 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
299rtems_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
311procedure 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
333This directive creates a message queue which resides
334on the local node with the user-defined name specified in name.
335For control and maintenance of the queue, RTEMS allocates and
336initializes a QCB.  Memory is allocated from the RTEMS Workspace
337for the specified count of messages, each of max_message_size
338bytes in length.  The RTEMS-assigned queue id, returned in id,
339is used to access the message queue.
340
341Specifying PRIORITY in attribute_set causes tasks
342waiting for a message to be serviced according to task priority.
343When FIFO is specified, waiting tasks are serviced in First
344In-First Out order.
345
346@subheading NOTES:
347
348This directive will not cause the calling task to be
349preempted.
350
351The following message queue attribute constants are
352defined 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
361Message queues should not be made global unless
362remote tasks must interact with the created message queue.  This
363is to avoid the system overhead incurred by the creation of a
364global message queue.  When a global message queue is created,
365the message queue's name and id must be transmitted to every
366node in the system for insertion in the local copy of the global
367object table.
368
369For GLOBAL message queues, the maximum message size
370is effectively limited to the longest message which the MPCI is
371capable of transmitting.
372
373The total number of global objects, including message
374queues, is limited by the maximum_global_objects field in the
375configuration 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
387rtems_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
397procedure 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
413This directive obtains the queue id associated with
414the queue name specified in name.  If the queue name is not
415unique, then the queue id will match one of the queues with that
416name.  However, this queue id is not guaranteed to correspond to
417the desired queue.  The queue id is used with other message
418related directives to access the message queue.
419
420@subheading NOTES:
421
422This directive will not cause the running task to be
423preempted.
424
425If node is @code{SEARCH_ALL_NODES}, all nodes are searched
426with the local node being searched first.  All other nodes are
427searched with the lowest numbered node searched first.
428
429If node is a valid node number which does not
430represent the local node, then only the message queues exported
431by the designated node are searched.
432
433This directive does not generate activity on remote
434nodes.  It accesses only the local copy of the global object
435table.
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
447rtems_status_code rtems_message_queue_delete(
448  rtems_id id
449);
450@end example
451@end ifset
452
453@ifset is-Ada
454@example
455procedure 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
469This directive deletes the message queue specified by
470id.  As a result of this directive, all tasks blocked waiting to
471receive a message from this queue will be readied and returned a
472status code which indicates that the message queue was deleted.
473If no tasks are waiting, but the queue contains messages, then
474RTEMS returns these message buffers back to the system message
475buffer pool.  The QCB for this queue as well as the memory for
476the message buffers is reclaimed by RTEMS.
477
478@subheading NOTES:
479
480The calling task will be preempted if its preemption
481mode is enabled and one or more local tasks with a higher
482priority than the calling task are waiting on the deleted queue.
483The calling task will NOT be preempted if the tasks that are
484waiting are remote tasks.
485
486The calling task does not have to be the task that
487created the queue, although the task and queue must reside on
488the same node.
489
490When the queue is deleted, any messages in the queue
491are returned to the free message buffer pool.  Any information
492stored in those messages is lost.
493
494When a global message queue is deleted, the message
495queue id must be transmitted to every node in the system for
496deletion from the local copy of the global object table.
497
498Proxies, used to represent remote tasks, are
499reclaimed 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
511rtems_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
521procedure 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
539This directive sends the message buffer of size bytes
540in length to the queue specified by id.  If a task is waiting at
541the queue, then the message is copied to the waiting task's
542buffer and the task is unblocked. If no tasks are waiting at the
543queue, then the message is copied to a message buffer which is
544obtained from this message queue's message buffer pool.  The
545message buffer is then placed at the rear of the queue.
546
547@subheading NOTES:
548
549The calling task will be preempted if it has
550preemption enabled and a higher priority task is unblocked as
551the result of this directive.
552
553Sending a message to a global message queue which
554does not reside on the local node will generate a request to the
555remote node to post the message on the specified message queue.
556
557If the task to be unblocked resides on a different
558node from the message queue, then the message is forwarded to
559the appropriate node, the waiting task is unblocked, and the
560proxy 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
572rtems_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
582procedure 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
600This directive sends the message buffer of size bytes
601in length to the queue specified by id.  If a task is waiting on
602the queue, then the message is copied to the task's buffer and
603the task is unblocked.  If no tasks are waiting on the queue,
604then the message is copied to a message buffer which is obtained
605from this message queue's message buffer pool.  The message
606buffer is then placed at the front of the queue.
607
608@subheading NOTES:
609
610The calling task will be preempted if it has
611preemption enabled and a higher priority task is unblocked as
612the result of this directive.
613
614Sending a message to a global message queue which
615does not reside on the local node will generate a request
616telling the remote node to post the message on the specified
617message queue.
618
619If the task to be unblocked resides on a different
620node from the message queue, then the message is forwarded to
621the appropriate node, the waiting task is unblocked, and the
622proxy 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
634rtems_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
645procedure 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
662This directive causes all tasks that are waiting at
663the queue specified by id to be unblocked and sent the message
664contained in buffer.  Before a task is unblocked, the message
665buffer of size byes in length is copied to that task's message
666buffer.  The number of tasks that were unblocked is returned in
667count.
668
669@subheading NOTES:
670
671The calling task will be preempted if it has
672preemption enabled and a higher priority task is unblocked as
673the result of this directive.
674
675The execution time of this directive is directly
676related to the number of tasks waiting on the message queue,
677although it is more efficient than the equivalent number of
678invocations of message_queue_send.
679
680Broadcasting a message to a global message queue
681which does not reside on the local node will generate a request
682telling the remote node to broadcast the message to the
683specified message queue.
684
685When a task is unblocked which resides on a different
686node from the message queue, a copy of the message is forwarded
687to the appropriate node,  the waiting task is unblocked, and the
688proxy 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
700rtems_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
712procedure 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
732This directive receives a message from the message
733queue specified in id.  The @code{WAIT} and @code{NO_WAIT} options of the
734options parameter allow the calling task to specify whether to
735wait for a message to become available or return immediately.
736For either option, if there is at least one message in the
737queue, then it is copied to buffer, size is set to return the
738length of the message in bytes, and this directive returns
739immediately with a successful return code.
740
741If the calling task chooses to return immediately and
742the queue is empty, then a status code indicating this condition
743is returned.  If the calling task chooses to wait at the message
744queue and the queue is empty, then the calling task is placed on
745the message wait queue and blocked.  If the queue was created
746with the PRIORITY option specified, then the calling task is
747inserted into the wait queue according to its priority.  But, if
748the queue was created with the FIFO option specified, then the
749calling task is placed at the rear of the wait queue.
750
751A task choosing to wait at the queue can optionally
752specify a timeout value in the timeout parameter.  The timeout
753parameter specifies the maximum interval to wait before the
754calling 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
759The following message receive option constants are
760defined 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
768Receiving a message from a global message queue which
769does not reside on the local node will generate a request to the
770remote node to obtain a message from the specified message
771queue.  If no message is available and @code{WAIT} was specified, then
772the task must be blocked until a message is posted.  A proxy is
773allocated on the remote node to represent the task until the
774message 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
786rtems_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
795procedure 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
809This directive removes all pending messages from the
810specified queue id.  The number of messages removed is returned
811in count.  If no messages are present on the queue, count is set
812to zero.
813
814@subheading NOTES:
815
816Flushing all messages on a global message queue which
817does not reside on the local node will generate a request to the
818remote node to actually flush the specified message queue.
819
820
821
Note: See TracBrowser for help on using the repository browser.