source: rtems/cpukit/rtems/src/msgqsubmit.c @ 8d37343

4.104.114.84.95
Last change on this file since 8d37343 was 53fb837a, checked in by Joel Sherrill <joel.sherrill@…>, on 01/13/00 at 19:25:15

POSIX message queues now include complete functionality including
blocking sends when the queue is full. The SuperCore? was enhanced
to support blocking on send. The existing POSIX API was debugged
and numerous test cases were added to psxmsgq01 by Jennifer Averett.
SuperCore? enhancements and resulting modifications to other APIs
were done by Joel.

There is one significant point of interpretation for the POSIX API.
What happens to threads already blocked on a message queue when the
mode of that same message queue is changed from blocking to non-blocking?
We decided to unblock all waiting tasks with an EAGAIN error just
as if a non-blocking version of the same operation had returned
unsatisfied. This case is not discussed in the POSIX standard and
other implementations may have chosen differently.

  • Property mode set to 100644
File size: 3.9 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
55rtems_status_code _Message_queue_Submit(
56  Objects_Id                  id,
57  void                       *buffer,
58  unsigned32                  size,
59  Message_queue_Submit_types  submit_type
60)
61{
62  register Message_queue_Control  *the_message_queue;
63  Objects_Locations                location;
64
65  the_message_queue = _Message_queue_Get( id, &location );
66  switch ( location )
67  {
68    case OBJECTS_REMOTE:
69#if defined(RTEMS_MULTIPROCESSING)
70      switch ( submit_type ) {
71        case MESSAGE_QUEUE_SEND_REQUEST:
72          return _Message_queue_MP_Send_request_packet(
73              MESSAGE_QUEUE_MP_SEND_REQUEST,
74              id,
75              buffer,
76              &size,
77              0,                               /* option_set */
78              MPCI_DEFAULT_TIMEOUT
79            );
80
81        case MESSAGE_QUEUE_URGENT_REQUEST:
82          return _Message_queue_MP_Send_request_packet(
83              MESSAGE_QUEUE_MP_URGENT_REQUEST,
84              id,
85              buffer,
86              &size,
87              0,                               /* option_set */
88              MPCI_DEFAULT_TIMEOUT
89            );
90      }
91      break;
92#endif
93
94    case OBJECTS_ERROR:
95      return RTEMS_INVALID_ID;
96
97    case OBJECTS_LOCAL:
98      switch ( submit_type ) {
99        case MESSAGE_QUEUE_SEND_REQUEST:
100          _CORE_message_queue_Send(
101            &the_message_queue->message_queue,
102            buffer,
103            size,
104            id,
105#if defined(RTEMS_MULTIPROCESSING)
106            _Message_queue_Core_message_queue_mp_support,
107#else
108            NULL,
109#endif
110            FALSE,   /* sender does not block */
111            0        /* no timeout */
112          );
113          break;
114        case MESSAGE_QUEUE_URGENT_REQUEST:
115          _CORE_message_queue_Urgent(
116            &the_message_queue->message_queue,
117            buffer,
118            size,
119            id,
120#if defined(RTEMS_MULTIPROCESSING)
121            _Message_queue_Core_message_queue_mp_support,
122#else
123            NULL,
124#endif
125            FALSE,   /* sender does not block */
126            0        /* no timeout */
127          );
128          break;
129        default:
130          return RTEMS_INTERNAL_ERROR;   /* should never get here */
131      }
132
133      _Thread_Enable_dispatch();
134      return _Message_queue_Translate_core_message_queue_return_code(
135        _Thread_Executing->Wait.return_code
136      );
137         
138  }
139  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
140}
Note: See TracBrowser for help on using the repository browser.