source: rtems/c/src/exec/rtems/include/rtems/rtems/message.h @ aee3d68

4.104.114.84.95
Last change on this file since aee3d68 was dd746c38, checked in by Joel Sherrill <joel.sherrill@…>, on 02/10/99 at 00:29:02

Comments fixed after problem report from Ian Lance Taylor <ian@…>.

  • Property mode set to 100644
File size: 8.7 KB
Line 
1/*  message.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Message Queue Manager.  This manager provides a mechanism for
5 *  communication and synchronization between tasks using messages.
6 *
7 *  Directives provided are:
8 *
9 *     + create a queue
10 *     + get ID of a queue
11 *     + delete a queue
12 *     + put a message at the rear of a queue
13 *     + put a message at the front of a queue
14 *     + broadcast N messages to a queue
15 *     + receive message from a queue
16 *     + flush all messages on a queue
17 *
18 *
19 *  COPYRIGHT (c) 1989-1998.
20 *  On-Line Applications Research Corporation (OAR).
21 *  Copyright assigned to U.S. Government, 1994.
22 *
23 *  The license and distribution terms for this file may be
24 *  found in the file LICENSE in this distribution or at
25 *  http://www.OARcorp.com/rtems/license.html.
26 *
27 *  $Id$
28 */
29
30#ifndef __RTEMS_MESSAGE_QUEUE_h
31#define __RTEMS_MESSAGE_QUEUE_h
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#include <rtems/rtems/types.h>
38#include <rtems/score/chain.h>
39#include <rtems/score/object.h>
40#include <rtems/rtems/attr.h>
41#include <rtems/score/threadq.h>
42#include <rtems/score/coremsg.h>
43
44/*
45 *  The following enumerated type details the modes in which a message
46 *  may be submitted to a message queue.  The message may be posted
47 *  in a send or urgent fashion.
48 */
49 
50typedef enum {
51  MESSAGE_QUEUE_SEND_REQUEST   = 0,
52  MESSAGE_QUEUE_URGENT_REQUEST = 1
53}  Message_queue_Submit_types;
54
55/*
56 *  The following records define the control block used to manage
57 *  each message queue.
58 */
59
60typedef struct {
61  Objects_Control             Object;
62  rtems_attribute             attribute_set;
63  CORE_message_queue_Control  message_queue;
64}   Message_queue_Control;
65
66/*
67 *  The following defines the information control block used to
68 *  manage this class of objects.
69 */
70
71RTEMS_EXTERN Objects_Information  _Message_queue_Information;
72
73/*
74 *  _Message_queue_Manager_initialization
75 *
76 *  DESCRIPTION:
77 *
78 *  This routine performs the initialization necessary for this manager.
79 */
80
81void _Message_queue_Manager_initialization(
82  unsigned32 maximum_message_queues
83);
84
85/*
86 *  rtems_message_queue_create
87 *
88 *  DESCRIPTION:
89 *
90 *  This routine implements the rtems_message_queue_create directive.  The
91 *  message queue will have the name name.  If the attribute_set indicates
92 *  that the message queue is to be limited in the number of messages
93 *  that can be outstanding, then count indicates the maximum number of
94 *  messages that will be held.  It returns the id of the created
95 *  message queue in ID.
96 */
97
98rtems_status_code rtems_message_queue_create(
99  rtems_name       name,
100  unsigned32       count,
101  unsigned32       max_message_size,
102  rtems_attribute  attribute_set,
103  Objects_Id      *id
104);
105
106/*
107 *  rtems_message_queue_ident
108 *
109 *  DESCRIPTION:
110 *
111 *  This routine implements the rtems_message_queue_ident directive.
112 *  This directive returns the message queue ID associated with NAME.
113 *  If more than one message queue is named name, then the message
114 *  queue to which the ID belongs is arbitrary.  node indicates the
115 *  extent of the search for the ID of the message queue named name.
116 *  The search can be limited to a particular node or allowed to
117 *  encompass all nodes.
118 */
119
120rtems_status_code rtems_message_queue_ident(
121  rtems_name    name,
122  unsigned32    node,
123  Objects_Id   *id
124);
125
126/*
127 *  rtems_message_queue_delete
128 *
129 *  DESCRIPTION:
130 *
131 *  This routine implements the rtems_message_queue_delete directive.  The
132 *  message queue indicated by ID is deleted.
133 */
134
135rtems_status_code rtems_message_queue_delete(
136  Objects_Id id
137);
138
139/*
140 *  rtems_message_queue_send
141 *
142 *  DESCRIPTION:
143 *
144 *  This routine implements the rtems_message_queue_send directive.
145 *  This directive sends the message buffer to the message queue
146 *  indicated by ID.  If one or more tasks is blocked waiting
147 *  to receive a message from this message queue, then one will
148 *  receive the message.  The task selected to receive the
149 *  message is based on the task queue discipline algorithm in
150 *  use by this particular message queue.  If no tasks are waiting,
151 *  then the message buffer will be placed at the REAR of the
152 *  chain of pending messages for this message queue.
153 */
154
155rtems_status_code rtems_message_queue_send(
156  Objects_Id            id,
157  void                 *buffer,
158  unsigned32            size
159);
160
161/*
162 *  rtems_message_queue_urgent
163 *
164 *  DESCRIPTION:
165 *
166 *  This routine implements the rtems_message_queue_urgent directive.
167 *  This directive has the same behavior as rtems_message_queue_send
168 *  except that if no tasks are waiting, the message buffer will
169 *  be placed at the FRONT of the chain of pending messages rather
170 *  than at the REAR.
171 */
172
173rtems_status_code rtems_message_queue_urgent(
174  Objects_Id            id,
175  void                 *buffer,
176  unsigned32            size
177);
178
179/*
180 *  rtems_message_queue_broadcast
181 *
182 *  DESCRIPTION:
183 *
184 *  This routine implements the rtems_message_queue_broadcast directive.
185 *  This directive sends the message buffer to all of the tasks blocked
186 *  waiting for a message on the message queue indicated by ID. 
187 *  If no tasks are waiting, then the message buffer will not be queued.
188 */
189
190rtems_status_code rtems_message_queue_broadcast(
191  Objects_Id            id,
192  void                 *buffer,
193  unsigned32            size,
194  unsigned32           *count
195);
196
197/*
198 *  rtems_message_queue_receive
199 *
200 *  DESCRIPTION:
201 *
202 *  This routine implements the rtems_message_queue_receive directive.
203 *  This directive is invoked when the calling task wishes to receive
204 *  a message from the message queue indicated by ID.  The received
205 *  message is to be placed in buffer.  If no messages are outstanding
206 *  and the option_set indicates that the task is willing to block,
207 *  then the task will be blocked until a message arrives or until,
208 *  optionally, timeout clock ticks have passed.
209 */
210
211rtems_status_code rtems_message_queue_receive(
212  Objects_Id            id,
213  void                 *buffer,
214  unsigned32           *size,
215  unsigned32            option_set,
216  rtems_interval        timeout
217);
218
219/*
220 *  rtems_message_queue_flush
221 *
222 *  DESCRIPTION:
223 *
224 *  This routine implements the rtems_message_queue_flush directive.
225 *  This directive takes all outstanding messages for the message
226 *  queue indicated by ID and returns them to the inactive message
227 *  chain.  The number of messages flushed is returned in COUNT.
228 */
229
230rtems_status_code rtems_message_queue_flush(
231  Objects_Id  id,
232  unsigned32 *count
233);
234
235/*
236 *  rtems_message_queue_get_number_pending
237 *
238 *  DESCRIPTION:
239 *
240 *  This routine implements the rtems_message_queue_get_number_pending
241 *  directive.  This directive returns the number of pending
242 *  messages for the message queue indicated by ID
243 *  chain.  The number of messages pending is returned in COUNT.
244 */
245
246rtems_status_code rtems_message_queue_get_number_pending(
247  Objects_Id  id,
248  unsigned32 *count
249);
250
251
252/*
253 *  _Message_queue_Submit
254 *
255 *  DESCRIPTION:
256 *
257 *  This routine implements the directives rtems_message_queue_send
258 *  and rtems_message_queue_urgent.  It processes a message that is
259 *  to be submitted to the designated message queue.  The message will
260 *  either be processed as a send send message which it will be inserted
261 *  at the rear of the queue or it will be processed as an urgent message
262 *  which will be inserted at the front of the queue.
263 */
264 
265rtems_status_code _Message_queue_Submit(
266  Objects_Id                  id,
267  void                       *buffer,
268  unsigned32                  size,
269  Message_queue_Submit_types  submit_type
270);
271
272/*
273 *  _Message_queue_Allocate
274 *
275 *  DESCRIPTION:
276 *
277 *  This function allocates a message queue control block from
278 *  the inactive chain of free message queue control blocks.
279 */
280
281Message_queue_Control *_Message_queue_Allocate (
282    unsigned32          count,
283    unsigned32          max_message_size
284);
285
286/*
287 *  _Message_queue_Translate_core_message_queue_return_code
288 *
289 *  DESCRIPTION:
290 *
291 *  This function returns a RTEMS status code based on the core message queue
292 *  status code specified.
293 */
294 
295rtems_status_code _Message_queue_Translate_core_message_queue_return_code (
296  unsigned32 the_message_queue_status
297);
298
299/*
300 *
301 *  _Message_queue_Core_message_queue_mp_support
302 *
303 *  Input parameters:
304 *    the_thread - the remote thread the message was submitted to
305 *    id         - id of the message queue
306 *
307 *  Output parameters: NONE
308 */
309 
310#if defined(RTEMS_MULTIPROCESSING)
311void  _Message_queue_Core_message_queue_mp_support (
312  Thread_Control *the_thread,
313  Objects_Id      id
314);
315#endif
316
317#ifndef __RTEMS_APPLICATION__
318#include <rtems/rtems/message.inl>
319#endif
320#if defined(RTEMS_MULTIPROCESSING)
321#include <rtems/rtems/msgmp.h>
322#endif
323
324#ifdef __cplusplus
325}
326#endif
327
328#endif
329/* end of include file */
Note: See TracBrowser for help on using the repository browser.