source: rtems/cpukit/rtems/src/msgqgetnumberpending.c @ ef6f8a83

5
Last change on this file since ef6f8a83 was 6741d30a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/16 at 04:49:59

rtems: Avoid Giant lock for message queues

Update #2555.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS Message Queue Get Number Pending
5 * @ingroup ClassicMessageQueue Message Queues
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
23rtems_status_code rtems_message_queue_get_number_pending(
24  rtems_id  id,
25  uint32_t *count
26)
27{
28  Message_queue_Control *the_message_queue;
29  Objects_Locations      location;
30  ISR_lock_Context       lock_context;
31
32  if ( !count )
33    return RTEMS_INVALID_ADDRESS;
34
35  the_message_queue = _Message_queue_Get_interrupt_disable(
36    id,
37    &location,
38    &lock_context
39  );
40  switch ( location ) {
41
42    case OBJECTS_LOCAL:
43      _CORE_message_queue_Acquire_critical(
44        &the_message_queue->message_queue,
45        &lock_context
46      );
47      *count = the_message_queue->message_queue.number_of_pending_messages;
48      _CORE_message_queue_Release(
49        &the_message_queue->message_queue,
50        &lock_context
51      );
52      return RTEMS_SUCCESSFUL;
53
54#if defined(RTEMS_MULTIPROCESSING)
55    case OBJECTS_REMOTE:
56      _Thread_Get_executing()->Wait.return_argument = count;
57
58      return _Message_queue_MP_Send_request_packet(
59          MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST,
60          id,
61          0,                               /* buffer not used */
62          0,                               /* size */
63          0,                               /* option_set not used */
64          MPCI_DEFAULT_TIMEOUT
65        );
66#endif
67
68    case OBJECTS_ERROR:
69      break;
70  }
71
72  return RTEMS_INVALID_ID;
73}
Note: See TracBrowser for help on using the repository browser.