source: rtems/c/src/exec/rtems/src/msgqreceive.c @ 53fb837a

4.104.114.84.95
Last change on this file since 53fb837a 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: 2.6 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 *  rtems_message_queue_receive
36 *
37 *  This directive dequeues a message from the designated message queue
38 *  and copies it into the requesting thread's buffer.
39 *
40 *  Input parameters:
41 *    id         - queue id
42 *    buffer     - pointer to message buffer
43 *    size       - size of message receive
44 *    option_set - options on receive
45 *    timeout    - number of ticks to wait
46 *
47 *  Output parameters:
48 *    RTEMS_SUCCESSFUL - if successful
49 *    error code       - if unsuccessful
50 */
51
52rtems_status_code rtems_message_queue_receive(
53  Objects_Id            id,
54  void                 *buffer,
55  unsigned32           *size,
56  unsigned32            option_set,
57  rtems_interval        timeout
58)
59{
60  register Message_queue_Control *the_message_queue;
61  Objects_Locations               location;
62  boolean                         wait;
63  CORE_message_queue_Submit_types core_priority;
64 
65  the_message_queue = _Message_queue_Get( id, &location );
66  switch ( location ) {
67
68    case OBJECTS_REMOTE:
69#if defined(RTEMS_MULTIPROCESSING)
70      return _Message_queue_MP_Send_request_packet(
71          MESSAGE_QUEUE_MP_RECEIVE_REQUEST,
72          id,
73          buffer,
74          size,
75          option_set,
76          timeout
77        );
78#endif
79
80    case OBJECTS_ERROR:
81      return RTEMS_INVALID_ID;
82
83    case OBJECTS_LOCAL:
84      if ( _Options_Is_no_wait( option_set ) )
85        wait = FALSE;
86      else
87        wait = TRUE;
88 
89      _CORE_message_queue_Seize(
90        &the_message_queue->message_queue,
91        the_message_queue->Object.id,
92        buffer,
93        size,
94        wait,
95        timeout
96      );
97      _Thread_Enable_dispatch();
98      return _Message_queue_Translate_core_message_queue_return_code(
99        _Thread_Executing->Wait.return_code
100      );
101
102  }
103
104  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
105}
Note: See TracBrowser for help on using the repository browser.