source: rtems/cpukit/rtems/src/msgqreceive.c @ 8866e62

5
Last change on this file since 8866e62 was 8866e62, checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/16 at 04:26:58

score: Move thread queue object support

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Message Queue Receive
5 *  @ingroup ClassicMessageQueue
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/messageimpl.h>
22#include <rtems/rtems/optionsimpl.h>
23
24THREAD_QUEUE_OBJECT_ASSERT( Message_queue_Control, message_queue.Wait_queue );
25
26rtems_status_code rtems_message_queue_receive(
27  rtems_id        id,
28  void           *buffer,
29  size_t         *size,
30  rtems_option    option_set,
31  rtems_interval  timeout
32)
33{
34  Message_queue_Control *the_message_queue;
35  ISR_lock_Context       lock_context;
36  Thread_Control        *executing;
37
38  if ( buffer == NULL ) {
39    return RTEMS_INVALID_ADDRESS;
40  }
41
42  if ( size == NULL ) {
43    return RTEMS_INVALID_ADDRESS;
44  }
45
46  the_message_queue = _Message_queue_Get( id, &lock_context );
47
48  if ( the_message_queue == NULL ) {
49#if defined(RTEMS_MULTIPROCESSING)
50    return _Message_queue_MP_Receive( id, buffer, size, option_set, timeout );
51#else
52    return RTEMS_INVALID_ID;
53#endif
54  }
55
56  _CORE_message_queue_Acquire_critical(
57    &the_message_queue->message_queue,
58    &lock_context
59  );
60
61  executing = _Thread_Executing;
62  _CORE_message_queue_Seize(
63    &the_message_queue->message_queue,
64    executing,
65    buffer,
66    size,
67    !_Options_Is_no_wait( option_set ),
68    timeout,
69    &lock_context
70  );
71  return _Message_queue_Translate_core_message_queue_return_code(
72    executing->Wait.return_code
73  );
74}
Note: See TracBrowser for help on using the repository browser.