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

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 11.8 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, 1990, 1991, 1992, 1993, 1994.
20 *  On-Line Applications Research Corporation (OAR).
21 *  All rights assigned to U.S. Government, 1994.
22 *
23 *  This material may be reproduced by or for the U.S. Government pursuant
24 *  to the copyright license under the clause at DFARS 252.227-7013.  This
25 *  notice must appear in all copies of this file and its derivatives.
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/chain.h>
38#include <rtems/object.h>
39#include <rtems/threadq.h>
40
41/*
42 *  The following defines the data types needed to manipulate
43 *  the contents of message buffers.
44 */
45
46typedef struct {
47  unsigned32 field1;
48  unsigned32 field2;
49  unsigned32 field3;
50  unsigned32 field4;
51}  Message_queue_Buffer;
52
53/*
54 *  The following records define the organization of a message
55 *  buffer.
56 */
57
58typedef struct {
59  Chain_Node           Node;
60  Message_queue_Buffer Contents;
61}   Message_queue_Buffer_control;
62
63/*
64 *  The following records define the control block used to manage
65 *  each message queue.
66 */
67
68typedef struct {
69  Objects_Control      Object;
70  Thread_queue_Control Wait_queue;
71  rtems_attribute   attribute_set;
72  unsigned32           maximum_pending_messages;
73  unsigned32           number_of_pending_messages;
74  Chain_Control        Pending_messages;
75}   Message_queue_Control;
76
77/*
78 *  The following defines the information control block used to
79 *  manage this class of objects.
80 */
81
82EXTERN Objects_Information  _Message_queue_Information;
83
84/*
85 *  The following defines the data structures used to
86 *  manage the pool of inactive message buffers.
87 */
88
89EXTERN Chain_Control _Message_queue_Inactive_messages;
90
91/*
92 *  The following enumerated type details the modes in which a message
93 *  may be submitted to a message queue.  The message may be posted
94 *  in a send or urgent fashion.
95 */
96
97typedef enum {
98  MESSAGE_QUEUE_SEND_REQUEST   = 0,
99  MESSAGE_QUEUE_URGENT_REQUEST = 1
100}  Message_queue_Submit_types;
101
102/*
103 *  _Message_queue_Manager_initialization
104 *
105 *  DESCRIPTION:
106 *
107 *  This routine performs the initialization necessary for this manager.
108 */
109
110void _Message_queue_Manager_initialization(
111  unsigned32 maximum_message_queues,
112  unsigned32 maximum_messages
113);
114
115/*
116 *  rtems_message_queue_create
117 *
118 *  DESCRIPTION:
119 *
120 *  This routine implements the rtems_message_queue_create directive.  The
121 *  message queue will have the name name.  If the attribute_set indicates
122 *  that the message queue is to be limited in the number of messages
123 *  that can be outstanding, then count indicates the maximum number of
124 *  messages that will be held.  It returns the id of the created
125 *  message queue in ID.
126 */
127
128rtems_status_code rtems_message_queue_create(
129  Objects_Name        name,
130  unsigned32          count,
131  rtems_attribute  attribute_set,
132  Objects_Id         *id
133);
134
135/*
136 *  rtems_message_queue_ident
137 *
138 *  DESCRIPTION:
139 *
140 *  This routine implements the rtems_message_queue_ident directive.
141 *  This directive returns the message queue ID associated with NAME.
142 *  If more than one message queue is named name, then the message
143 *  queue to which the ID belongs is arbitrary.  node indicates the
144 *  extent of the search for the ID of the message queue named name.
145 *  The search can be limited to a particular node or allowed to
146 *  encompass all nodes.
147 */
148
149rtems_status_code rtems_message_queue_ident(
150  Objects_Name  name,
151  unsigned32    node,
152  Objects_Id   *id
153);
154
155/*
156 *  rtems_message_queue_delete
157 *
158 *  DESCRIPTION:
159 *
160 *  This routine implements the rtems_message_queue_delete directive.  The
161 *  message queue indicated by ID is deleted.
162 */
163
164rtems_status_code rtems_message_queue_delete(
165  Objects_Id id
166);
167
168/*
169 *  rtems_message_queue_send
170 *
171 *  DESCRIPTION:
172 *
173 *  This routine implements the rtems_message_queue_send directive.
174 *  This directive sends the message buffer to the message queue
175 *  indicated by ID.  If one or more tasks is blocked waiting
176 *  to receive a message from this message queue, then one will
177 *  receive the message.  The task selected to receive the
178 *  message is based on the task queue discipline algorithm in
179 *  use by this particular message queue.  If no tasks are waiting,
180 *  then the message buffer will be placed at the rear of the
181 *  chain of pending messages for this message queue.
182 */
183
184rtems_status_code rtems_message_queue_send(
185  Objects_Id            id,
186  void                 *buffer
187);
188
189/*
190 *  rtems_message_queue_urgent
191 *
192 *  DESCRIPTION:
193 *
194 *  This routine implements the rtems_message_queue_send directive.
195 *  This directive sends the message buffer to the message queue
196 *  indicated by ID.  If one or more tasks is blocked waiting
197 *  to receive a message from this message queue, then one will
198 *  receive the message.  The task selected to receive the
199 *  message is based on the task queue discipline algorithm in
200 *  use by this particular message queue.  If no tasks are waiting,
201 *  then the message buffer will be placed at the rear of the
202 *  chain of pending messages for this message queue.
203 */
204
205rtems_status_code rtems_message_queue_urgent(
206  Objects_Id            id,
207  void                 *buffer
208);
209
210/*
211 *  rtems_message_queue_broadcast
212 *
213 *  DESCRIPTION:
214 *
215 *  This routine implements the rtems_message_queue_send directive.
216 *  This directive sends the message buffer to the message queue
217 *  indicated by ID.  If one or more tasks is blocked waiting
218 *  to receive a message from this message queue, then one will
219 *  receive the message.  The task selected to receive the
220 *  message is based on the task queue discipline algorithm in
221 *  use by this particular message queue.  If no tasks are waiting,
222 *  then the message buffer will be placed at the rear of the
223 *  chain of pending messages for this message queue.
224 */
225
226rtems_status_code rtems_message_queue_broadcast(
227  Objects_Id            id,
228  void                 *buffer,
229  unsigned32           *count
230);
231
232/*
233 *  rtems_message_queue_receive
234 *
235 *  DESCRIPTION:
236 *
237 *  This routine implements the rtems_message_queue_receive directive.
238 *  This directive is invoked when the calling task wishes to receive
239 *  a message from the message queue indicated by ID.  The received
240 *  message is to be placed in buffer.  If no messages are outstanding
241 *  and the option_set indicates that the task is willing to block,
242 *  then the task will be blocked until a message arrives or until,
243 *  optionally, timeout clock ticks have passed.
244 */
245
246rtems_status_code rtems_message_queue_receive(
247  Objects_Id            id,
248  void                 *buffer,
249  unsigned32            option_set,
250  rtems_interval     timeout
251);
252
253/*
254 *  rtems_message_queue_flush
255 *
256 *  DESCRIPTION:
257 *
258 *  This routine implements the rtems_message_queue_flush directive.
259 *  This directive takes all outstanding messages for the message
260 *  queue indicated by ID and returns them to the inactive message
261 *  chain.  The number of messages flushed is returned in COUNT.
262 */
263
264rtems_status_code rtems_message_queue_flush(
265  Objects_Id  id,
266  unsigned32 *count
267);
268
269/*
270 *  _Message_queue_Copy_buffer
271 *
272 *  DESCRIPTION:
273 *
274 *  This routine copies the contents of the source message buffer
275 *  to the destination message buffer.
276 */
277
278STATIC INLINE void _Message_queue_Copy_buffer (
279  Message_queue_Buffer *source,
280  Message_queue_Buffer *destination
281);
282
283/*
284 *  _Message_queue_Seize
285 *
286 *  DESCRIPTION:
287 *
288 *  This routine attempts to receive a message from the_message_queue.
289 *  If a message is available or if the RTEMS_NO_WAIT option is enabled in
290 *  option_set, then the routine returns.  Otherwise, the calling task
291 *  is blocked until a message is available.  If a message is returned
292 *  to the task, then buffer will contain its contents.
293 */
294
295boolean _Message_queue_Seize(
296  Message_queue_Control *the_message_queue,
297  unsigned32             option_set,
298  Message_queue_Buffer  *buffer
299);
300
301/*
302 *  _Message_queue_Flush_support
303 *
304 *  DESCRIPTION:
305 *
306 *  This routine flushes all outstanding messages and returns
307 *  them to the inactive message chain.
308 */
309
310unsigned32 _Message_queue_Flush_support(
311  Message_queue_Control *the_message_queue
312);
313
314/*
315 *  _Message_queue_Submit
316 *
317 *  DESCRIPTION:
318 *
319 *  This routine provides the common foundation for the
320 *  rtems_message_queue_send and rtems_message_queue_urgent directives.
321 */
322
323rtems_status_code _Message_queue_Submit(
324  Objects_Id                  id,
325  Message_queue_Buffer       *buffer,
326  Message_queue_Submit_types  submit_type
327);
328
329/*
330 *  _Message_queue_Allocate_message_buffer
331 *
332 *  DESCRIPTION:
333 *
334 *  This function allocates a message buffer from the inactive
335 *  message buffer chain.
336 */
337
338STATIC INLINE Message_queue_Buffer_control *
339  _Message_queue_Allocate_message_buffer ( void );
340
341/*
342 *  _Message_queue_Free_message_buffer
343 *
344 *  DESCRIPTION:
345 *
346 *  This routine frees a message buffer to the inactive
347 *  message buffer chain.
348 */
349
350STATIC INLINE void _Message_queue_Free_message_buffer (
351  Message_queue_Buffer_control *the_message
352);
353
354/*
355 *  _Message_queue_Get_pending_message
356 *
357 *  DESCRIPTION:
358 *
359 *  This function removes the first message from the_message_queue
360 *  and returns a pointer to it.
361 */
362
363STATIC INLINE
364  Message_queue_Buffer_control *_Message_queue_Get_pending_message (
365  Message_queue_Control *the_message_queue
366);
367
368/*
369 *  _Message_queue_Append
370 *
371 *  DESCRIPTION:
372 *
373 *  This routine places the_message at the rear of the outstanding
374 *  messages on the_message_queue.
375 */
376
377STATIC INLINE void _Message_queue_Append (
378  Message_queue_Control        *the_message_queue,
379  Message_queue_Buffer_control *the_message
380);
381
382/*
383 *  _Message_queue_Prepend
384 *
385 *  DESCRIPTION:
386 *
387 *  This routine places the_message at the rear of the outstanding
388 *  messages on the_message_queue.
389 */
390
391STATIC INLINE void _Message_queue_Prepend (
392  Message_queue_Control        *the_message_queue,
393  Message_queue_Buffer_control *the_message
394);
395
396/*
397 *  _Message_queue_Is_null
398 *
399 *  DESCRIPTION:
400 *
401 *  This function places the_message at the rear of the outstanding
402 *  messages on the_message_queue.
403 */
404
405STATIC INLINE boolean _Message_queue_Is_null (
406  Message_queue_Control *the_message_queue
407);
408
409/*
410 *  _Message_queue_Allocate
411 *
412 *  DESCRIPTION:
413 *
414 *  This function allocates a message queue control block from
415 *  the inactive chain of free message queue control blocks.
416 */
417
418STATIC INLINE Message_queue_Control *_Message_queue_Allocate ( void );
419
420/*
421 *  _Message_queue_Free
422 *
423 *  DESCRIPTION:
424 *
425 *  This routine allocates a message queue control block from
426 *  the inactive chain of free message queue control blocks.
427 */
428
429STATIC INLINE void _Message_queue_Free (
430  Message_queue_Control *the_message_queue
431);
432
433/*
434 *  _Message_queue_Get
435 *
436 *  DESCRIPTION:
437 *
438 *  This function maps message queue IDs to message queue control
439 *  blocks.  If ID corresponds to a local message queue, then it
440 *  returns the_message_queue control pointer which maps to ID
441 *  and location is set to OBJECTS_LOCAL.  If the message queue ID is
442 *  global and resides on a remote node, then location is set
443 *  to OBJECTS_REMOTE, and the_message_queue is undefined.
444 *  Otherwise, location is set to OBJECTS_ERROR and
445 *  the_message_queue is undefined.
446 */
447
448STATIC INLINE Message_queue_Control *_Message_queue_Get (
449  Objects_Id         id,
450  Objects_Locations *location
451);
452
453#include <rtems/message.inl>
454#include <rtems/msgmp.h>
455
456#ifdef __cplusplus
457}
458#endif
459
460#endif
461/* end of include file */
Note: See TracBrowser for help on using the repository browser.