source: rtems/cpukit/rtems/src/msgqurgent.c @ 99112f7

5
Last change on this file since 99112f7 was 99112f7, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/16 at 14:21:07

score: _CORE_message_queue_Submit()

Move lock acquire to caller of _CORE_message_queue_Submit() to allow
state checks during send operations under lock protection.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Urgent Message Queue
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/system.h>
22#include <rtems/score/chain.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/coremsgimpl.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/wkspace.h>
27#include <rtems/rtems/status.h>
28#include <rtems/rtems/attrimpl.h>
29#include <rtems/rtems/messageimpl.h>
30#include <rtems/rtems/options.h>
31#include <rtems/rtems/support.h>
32
33rtems_status_code rtems_message_queue_urgent(
34  rtems_id    id,
35  const void *buffer,
36  size_t      size
37)
38{
39  Message_queue_Control           *the_message_queue;
40  Objects_Locations                location;
41  CORE_message_queue_Status        status;
42  ISR_lock_Context                 lock_context;
43
44  if ( !buffer )
45    return RTEMS_INVALID_ADDRESS;
46
47  the_message_queue = _Message_queue_Get_interrupt_disable(
48    id,
49    &location,
50    &lock_context
51  );
52  switch ( location ) {
53
54    case OBJECTS_LOCAL:
55      _CORE_message_queue_Acquire_critical(
56        &the_message_queue->message_queue,
57        &lock_context
58      );
59      status = _CORE_message_queue_Urgent(
60        &the_message_queue->message_queue,
61        buffer,
62        size,
63        _Message_queue_Core_message_queue_mp_support,
64        id,
65        false,   /* sender does not block */
66        0,       /* no timeout */
67        &lock_context
68      );
69
70      /*
71       *  Since this API does not allow for blocking sends, we can directly
72       *  return the returned status.
73       */
74
75      return _Message_queue_Translate_core_message_queue_return_code(status);
76
77#if defined(RTEMS_MULTIPROCESSING)
78    case OBJECTS_REMOTE:
79      return _Message_queue_MP_Send_request_packet(
80        MESSAGE_QUEUE_MP_URGENT_REQUEST,
81        id,
82        buffer,
83        &size,
84        0,                               /* option_set */
85        MPCI_DEFAULT_TIMEOUT
86      );
87#endif
88
89    case OBJECTS_ERROR:
90      break;
91  }
92
93  return RTEMS_INVALID_ID;
94}
Note: See TracBrowser for help on using the repository browser.