source: rtems/cpukit/rtems/src/msgqcreate.c @ 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: 4.3 KB
Line 
1/*
2 *  Message Queue Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 */
12
13#if HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <rtems/system.h>
18#include <rtems/score/sysstate.h>
19#include <rtems/score/chain.h>
20#include <rtems/score/isr.h>
21#include <rtems/score/coremsg.h>
22#include <rtems/score/object.h>
23#include <rtems/score/states.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/wkspace.h>
26#if defined(RTEMS_MULTIPROCESSING)
27#include <rtems/score/mpci.h>
28#endif
29#include <rtems/rtems/status.h>
30#include <rtems/rtems/attr.h>
31#include <rtems/rtems/message.h>
32#include <rtems/rtems/options.h>
33#include <rtems/rtems/support.h>
34
35/*
36 *  rtems_message_queue_create
37 *
38 *  This directive creates a message queue by allocating and initializing
39 *  a message queue data structure.
40 *
41 *  Input parameters:
42 *    name             - user defined queue name
43 *    count            - maximum message and reserved buffer count
44 *    max_message_size - maximum size of each message
45 *    attribute_set    - process method
46 *    id               - pointer to queue
47 *
48 *  Output parameters:
49 *    id                - queue id
50 *    RTEMS_SUCCESSFUL  - if successful
51 *    error code        - if unsuccessful
52 */
53
54rtems_status_code rtems_message_queue_create(
55  rtems_name       name,
56  uint32_t         count,
57  size_t           max_message_size,
58  rtems_attribute  attribute_set,
59  rtems_id        *id
60)
61{
62  register Message_queue_Control *the_message_queue;
63  CORE_message_queue_Attributes   the_msgq_attributes;
64#if defined(RTEMS_MULTIPROCESSING)
65  bool                            is_global;
66  size_t                          max_packet_payload_size;
67#endif
68
69  if ( !rtems_is_name_valid( name ) )
70    return RTEMS_INVALID_NAME;
71
72  if ( !id )
73    return RTEMS_INVALID_ADDRESS;
74
75#if defined(RTEMS_MULTIPROCESSING)
76  if ( (is_global = _Attributes_Is_global( attribute_set ) ) &&
77       !_System_state_Is_multiprocessing )
78    return RTEMS_MP_NOT_CONFIGURED;
79#endif
80
81  if ( count == 0 )
82      return RTEMS_INVALID_NUMBER;
83
84  if ( max_message_size == 0 )
85      return RTEMS_INVALID_SIZE;
86
87#if defined(RTEMS_MULTIPROCESSING)
88#if 1
89  /*
90   * I am not 100% sure this should be an error.
91   * It seems reasonable to create a que with a large max size,
92   * and then just send smaller msgs from remote (or all) nodes.
93   */
94
95  max_packet_payload_size = _MPCI_table->maximum_packet_size
96    - MESSAGE_QUEUE_MP_PACKET_SIZE;
97  if ( is_global && max_packet_payload_size < max_message_size )
98    return RTEMS_INVALID_SIZE;
99#endif
100#endif
101
102  _Thread_Disable_dispatch();              /* protects object pointer */
103
104  the_message_queue = _Message_queue_Allocate();
105
106  if ( !the_message_queue ) {
107    _Thread_Enable_dispatch();
108    return RTEMS_TOO_MANY;
109  }
110
111#if defined(RTEMS_MULTIPROCESSING)
112  if ( is_global &&
113    !( _Objects_MP_Allocate_and_open( &_Message_queue_Information,
114                              name, the_message_queue->Object.id, false ) ) ) {
115    _Message_queue_Free( the_message_queue );
116    _Thread_Enable_dispatch();
117    return RTEMS_TOO_MANY;
118  }
119#endif
120
121  the_message_queue->attribute_set = attribute_set;
122
123  if (_Attributes_Is_priority( attribute_set ) )
124    the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
125  else
126    the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
127
128  if ( ! _CORE_message_queue_Initialize(
129           &the_message_queue->message_queue,
130           &the_msgq_attributes,
131           count,
132           max_message_size
133         ) ) {
134#if defined(RTEMS_MULTIPROCESSING)
135    if ( is_global )
136        _Objects_MP_Close(
137          &_Message_queue_Information, the_message_queue->Object.id);
138#endif
139
140    _Message_queue_Free( the_message_queue );
141    _Thread_Enable_dispatch();
142    return RTEMS_UNSATISFIED;
143  }
144
145  _Objects_Open(
146    &_Message_queue_Information,
147    &the_message_queue->Object,
148    (Objects_Name) name
149  );
150
151  *id = the_message_queue->Object.id;
152
153#if defined(RTEMS_MULTIPROCESSING)
154  if ( is_global )
155    _Message_queue_MP_Send_process_packet(
156      MESSAGE_QUEUE_MP_ANNOUNCE_CREATE,
157      the_message_queue->Object.id,
158      name,
159      0
160    );
161#endif
162
163  _Thread_Enable_dispatch();
164  return RTEMS_SUCCESSFUL;
165}
Note: See TracBrowser for help on using the repository browser.