source: rtems/c/src/exec/rtems/src/msgqsubmit.c @ 7d741413

4.104.114.84.95
Last change on this file since 7d741413 was f879de5, checked in by Joel Sherrill <joel.sherrill@…>, on 08/16/01 at 19:32:19

2001-08-16 Joel Sherrill <joel@…>

  • src/msgqsubmit.c: Add a comment indicating that we do not have to account for possibly blocking during the core send operation because Classic API message queue send is always non-blocking.
  • Property mode set to 100644
File size: 4.1 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.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/score/sysstate.h>
17#include <rtems/score/chain.h>
18#include <rtems/score/isr.h>
19#include <rtems/score/coremsg.h>
20#include <rtems/score/object.h>
21#include <rtems/score/states.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24#if defined(RTEMS_MULTIPROCESSING)
25#include <rtems/score/mpci.h>
26#endif
27#include <rtems/rtems/status.h>
28#include <rtems/rtems/attr.h>
29#include <rtems/rtems/message.h>
30#include <rtems/rtems/options.h>
31#include <rtems/rtems/support.h>
32
33/*PAGE
34 *
35 *  _Message_queue_Submit
36 *
37 *  This routine implements the directives rtems_message_queue_send
38 *  and rtems_message_queue_urgent.  It processes a message that is
39 *  to be submitted to the designated message queue.  The message will
40 *  either be processed as a send send message which it will be inserted
41 *  at the rear of the queue or it will be processed as an urgent message
42 *  which will be inserted at the front of the queue.
43 *
44 *  Input parameters:
45 *    id          - pointer to message queue
46 *    buffer      - pointer to message buffer
47 *    size        - size in bytes of message to send
48 *    submit_type - send or urgent message
49 *
50 *  Output parameters:
51 *    RTEMS_SUCCESSFUL - if successful
52 *    error code       - if unsuccessful
53 */
54
55#if defined(RTEMS_MULTIPROCESSING)
56#define MESSAGE_QUEUE_MP_HANDLER _Message_queue_Core_message_queue_mp_support
57#else
58#define MESSAGE_QUEUE_MP_HANDLER NULL
59#endif
60
61rtems_status_code _Message_queue_Submit(
62  Objects_Id                  id,
63  void                       *buffer,
64  unsigned32                  size,
65  Message_queue_Submit_types  submit_type
66)
67{
68  register Message_queue_Control  *the_message_queue;
69  Objects_Locations                location;
70  CORE_message_queue_Status        msg_status;
71
72  the_message_queue = _Message_queue_Get( id, &location );
73  switch ( location )
74  {
75    case OBJECTS_REMOTE:
76#if defined(RTEMS_MULTIPROCESSING)
77      switch ( submit_type ) {
78        case MESSAGE_QUEUE_SEND_REQUEST:
79          return _Message_queue_MP_Send_request_packet(
80              MESSAGE_QUEUE_MP_SEND_REQUEST,
81              id,
82              buffer,
83              &size,
84              0,                               /* option_set */
85              MPCI_DEFAULT_TIMEOUT
86            );
87
88        case MESSAGE_QUEUE_URGENT_REQUEST:
89          return _Message_queue_MP_Send_request_packet(
90              MESSAGE_QUEUE_MP_URGENT_REQUEST,
91              id,
92              buffer,
93              &size,
94              0,                               /* option_set */
95              MPCI_DEFAULT_TIMEOUT
96            );
97      }
98      break;
99#endif
100
101    case OBJECTS_ERROR:
102      return RTEMS_INVALID_ID;
103
104    case OBJECTS_LOCAL:
105      switch ( submit_type ) {
106        case MESSAGE_QUEUE_SEND_REQUEST:
107          msg_status = _CORE_message_queue_Send(
108            &the_message_queue->message_queue,
109            buffer,
110            size,
111            id,
112            MESSAGE_QUEUE_MP_HANDLER,
113            FALSE,   /* sender does not block */
114            0        /* no timeout */
115          );
116          break;
117        case MESSAGE_QUEUE_URGENT_REQUEST:
118          msg_status = _CORE_message_queue_Urgent(
119            &the_message_queue->message_queue,
120            buffer,
121            size,
122            id,
123            MESSAGE_QUEUE_MP_HANDLER,
124            FALSE,   /* sender does not block */
125            0        /* no timeout */
126          );
127          break;
128        default:
129          return RTEMS_INTERNAL_ERROR;   /* should never get here */
130      }
131
132      _Thread_Enable_dispatch();
133
134      /*
135       *  Since this API does not allow for blocking sends, we can directly
136       *  return the returned msg_status.
137       */
138
139      return
140        _Message_queue_Translate_core_message_queue_return_code( msg_status );
141         
142  }
143  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
144}
Note: See TracBrowser for help on using the repository browser.