source: rtems/doc/user/msg.t @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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