source: rtems/cpukit/rtems/src/msgqreceive.c @ 811804fe

4.104.114.84.95
Last change on this file since 811804fe was 1e1b3e00, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/99 at 22:52:59

Split Message Manager into one routine per file.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  Message Queue Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/score/sysstate.h>
18#include <rtems/score/chain.h>
19#include <rtems/score/isr.h>
20#include <rtems/score/coremsg.h>
21#include <rtems/score/object.h>
22#include <rtems/score/states.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/wkspace.h>
25#if defined(RTEMS_MULTIPROCESSING)
26#include <rtems/score/mpci.h>
27#endif
28#include <rtems/rtems/status.h>
29#include <rtems/rtems/attr.h>
30#include <rtems/rtems/message.h>
31#include <rtems/rtems/options.h>
32#include <rtems/rtems/support.h>
33
34/*PAGE
35 *
36 *  rtems_message_queue_receive
37 *
38 *  This directive dequeues a message from the designated message queue
39 *  and copies it into the requesting thread's buffer.
40 *
41 *  Input parameters:
42 *    id         - queue id
43 *    buffer     - pointer to message buffer
44 *    size       - size of message receive
45 *    option_set - options on receive
46 *    timeout    - number of ticks to wait
47 *
48 *  Output parameters:
49 *    RTEMS_SUCCESSFUL - if successful
50 *    error code       - if unsuccessful
51 */
52
53rtems_status_code rtems_message_queue_receive(
54  Objects_Id            id,
55  void                 *buffer,
56  unsigned32           *size,
57  unsigned32            option_set,
58  rtems_interval        timeout
59)
60{
61  register Message_queue_Control *the_message_queue;
62  Objects_Locations               location;
63  boolean                         wait;
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  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
104}
Note: See TracBrowser for help on using the repository browser.