source: rtems/cpukit/rtems/src/msgqreceive.c @ 66cb142

5
Last change on this file since 66cb142 was c3105894, checked in by Sebastian Huber <sebastian.huber@…>, on 10/19/17 at 11:47:57

score: Move thread queue timeout handling

Update #3117.
Update #3182.

  • Property mode set to 100644
File size: 1.7 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#include <rtems/rtems/statusimpl.h>
24
25THREAD_QUEUE_OBJECT_ASSERT( Message_queue_Control, message_queue.Wait_queue );
26
27rtems_status_code rtems_message_queue_receive(
28  rtems_id        id,
29  void           *buffer,
30  size_t         *size,
31  rtems_option    option_set,
32  rtems_interval  timeout
33)
34{
35  Message_queue_Control *the_message_queue;
36  Thread_queue_Context   queue_context;
37  Thread_Control        *executing;
38  Status_Control         status;
39
40  if ( buffer == NULL ) {
41    return RTEMS_INVALID_ADDRESS;
42  }
43
44  if ( size == NULL ) {
45    return RTEMS_INVALID_ADDRESS;
46  }
47
48  the_message_queue = _Message_queue_Get( id, &queue_context );
49
50  if ( the_message_queue == NULL ) {
51#if defined(RTEMS_MULTIPROCESSING)
52    return _Message_queue_MP_Receive( id, buffer, size, option_set, timeout );
53#else
54    return RTEMS_INVALID_ID;
55#endif
56  }
57
58  _CORE_message_queue_Acquire_critical(
59    &the_message_queue->message_queue,
60    &queue_context
61  );
62
63  executing = _Thread_Executing;
64  _Thread_queue_Context_set_enqueue_timeout_ticks( &queue_context, timeout );
65  status = _CORE_message_queue_Seize(
66    &the_message_queue->message_queue,
67    executing,
68    buffer,
69    size,
70    !_Options_Is_no_wait( option_set ),
71    &queue_context
72  );
73  return _Status_Get( status );
74}
Note: See TracBrowser for help on using the repository browser.