source: rtems/cpukit/rtems/src/msgqgetnumberpending.c @ 1e1b3e00

4.104.114.84.95
Last change on this file since 1e1b3e00 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.3 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_get_number_pending
37 *
38 *  This directive returns the number of messages pending.
39 *
40 *  Input parameters:
41 *    id    - queue id
42 *    count - return area for count
43 *
44 *  Output parameters:
45 *    count             - number of messages removed ( 0 = empty queue )
46 *    RTEMS_SUCCESSFUL - if successful
47 *    error code        - if unsuccessful
48 */
49
50rtems_status_code rtems_message_queue_get_number_pending(
51  Objects_Id  id,
52  unsigned32 *count
53)
54{
55  register Message_queue_Control *the_message_queue;
56  Objects_Locations               location;
57
58  the_message_queue = _Message_queue_Get( id, &location );
59  switch ( location ) {
60    case OBJECTS_REMOTE:
61#if defined(RTEMS_MULTIPROCESSING)
62      _Thread_Executing->Wait.return_argument = count;
63
64      return _Message_queue_MP_Send_request_packet(
65          MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST,
66          id,
67          0,                               /* buffer not used */
68          0,                               /* size */
69          0,                               /* option_set not used */
70          MPCI_DEFAULT_TIMEOUT
71        );
72#endif
73
74    case OBJECTS_ERROR:
75      return RTEMS_INVALID_ID;
76
77    case OBJECTS_LOCAL:
78      *count = the_message_queue->message_queue.number_of_pending_messages;
79      _Thread_Enable_dispatch();
80      return RTEMS_SUCCESSFUL;
81  }
82
83  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
84}
Note: See TracBrowser for help on using the repository browser.