source: rtems/cpukit/rtems/include/rtems/rtems/messageimpl.h @ 23fec9f0

4.115
Last change on this file since 23fec9f0 was 23fec9f0, checked in by Sebastian Huber <sebastian.huber@…>, on 03/27/14 at 13:16:12

score: PR2152: Use allocator mutex for objects

Use allocator mutex for objects allocate/free. This prevents that the
thread dispatch latency depends on the workspace/heap fragmentation.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/**
2 * @file rtems/rtems/message.inl
3 *
4 *  This include file contains the static inline implementation of all
5 *  inlined routines in the Message Manager.
6 */
7
8/*  COPYRIGHT (c) 1989-2008.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#ifndef _RTEMS_RTEMS_MESSAGEIMPL_H
17#define _RTEMS_RTEMS_MESSAGEIMPL_H
18
19#include <rtems/rtems/message.h>
20#include <rtems/score/objectimpl.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/**
27 *  @defgroup ClassicMessageQueueImpl Classic Message Queue Implementation
28 *
29 *  @ingroup ClassicMessageQueue
30 *
31 *  @{
32 */
33
34/**
35 *  This constant is defined to extern most of the time when using
36 *  this header file.  However by defining it to nothing, the data
37 *  declared in this header file can be instantiated.  This is done
38 *  in a single per manager file.
39 */
40#ifndef RTEMS_MESSAGE_EXTERN
41#define RTEMS_MESSAGE_EXTERN extern
42#endif
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 */
49typedef enum {
50  /**
51   *  This value indicates the user wants to send the message using the
52   *  normal message insertion protocol (FIFO or priority).
53   */
54  MESSAGE_QUEUE_SEND_REQUEST   = 0,
55  /**
56   *  This value indicates the user considers the message to be urgent
57   *  and wants it inserted at the head of the pending message queue.
58   */
59  MESSAGE_QUEUE_URGENT_REQUEST = 1
60}  Message_queue_Submit_types;
61
62/**
63 *  The following defines the information control block used to
64 *  manage this class of objects.
65 */
66RTEMS_MESSAGE_EXTERN Objects_Information  _Message_queue_Information;
67
68/**
69 *  @brief Message Queue Manager Initialization
70 *
71 *  This routine performs the initialization necessary for this manager.
72 */
73void _Message_queue_Manager_initialization(void);
74
75/**
76 *  @brief Message_queue_Submit
77 *
78 *  This routine implements the directives rtems_message_queue_send
79 *  and rtems_message_queue_urgent.  It processes a message that is
80 *  to be submitted to the designated message queue.  The message will
81 *  either be processed as a send send message which it will be inserted
82 *  at the rear of the queue or it will be processed as an urgent message
83 *  which will be inserted at the front of the queue.
84 */
85rtems_status_code _Message_queue_Submit(
86  rtems_id                    id,
87  const void                 *buffer,
88  size_t                      size,
89  Message_queue_Submit_types  submit_type
90);
91
92/**
93 * @brief Message queue Translate Core Message Queue Return Code
94 *
95 * This function returns a RTEMS status code based on
96 * @a the_message_queue_status.
97 *
98 * @param[in] the_message_queue_status is the status code to translate
99 *
100 * @retval translated RTEMS status code
101 */
102rtems_status_code _Message_queue_Translate_core_message_queue_return_code (
103  uint32_t   the_message_queue_status
104);
105
106/**
107 *  @brief Check whether message queue is null.
108 *
109 *  This function places the_message at the rear of the outstanding
110 *  messages on the_message_queue.
111 */
112RTEMS_INLINE_ROUTINE bool _Message_queue_Is_null (
113  Message_queue_Control *the_message_queue
114)
115{
116  return ( the_message_queue == NULL  );
117}
118
119
120/**
121 *  @brief Deallocates a message queue control block into
122 *  the inactive chain of free message queue control blocks.
123 *
124 *  This routine deallocates a message queue control block into
125 *  the inactive chain of free message queue control blocks.
126 */
127RTEMS_INLINE_ROUTINE void _Message_queue_Free (
128  Message_queue_Control *the_message_queue
129)
130{
131  _Objects_Free( &_Message_queue_Information, &the_message_queue->Object );
132}
133
134/**
135 *  @brief Maps message queue IDs to message queue control blocks.
136 *
137 *  This function maps message queue IDs to message queue control
138 *  blocks.  If ID corresponds to a local message queue, then it
139 *  returns the_message_queue control pointer which maps to ID
140 *  and location is set to OBJECTS_LOCAL.  If the message queue ID is
141 *  global and resides on a remote node, then location is set
142 *  to OBJECTS_REMOTE, and the_message_queue is undefined.
143 *  Otherwise, location is set to OBJECTS_ERROR and
144 *  the_message_queue is undefined.
145 */
146RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get (
147  Objects_Id         id,
148  Objects_Locations *location
149)
150{
151  return (Message_queue_Control *)
152     _Objects_Get( &_Message_queue_Information, id, location );
153}
154
155RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Allocate( void )
156{
157  return (Message_queue_Control *)
158    _Objects_Allocate( &_Message_queue_Information );
159}
160
161/**@}*/
162
163#ifdef __cplusplus
164}
165#endif
166
167#if defined(RTEMS_MULTIPROCESSING)
168#include <rtems/rtems/msgmp.h>
169#endif
170
171#endif
172/* end of include file */
Note: See TracBrowser for help on using the repository browser.