source: rtems/cpukit/rtems/src/msgqgetnumberpending.c @ 8ef3818

4.104.114.84.95
Last change on this file since 8ef3818 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  Message Queue Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/score/sysstate.h>
17#include <rtems/score/chain.h>
18#include <rtems/score/isr.h>
19#include <rtems/score/coremsg.h>
20#include <rtems/score/object.h>
21#include <rtems/score/states.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24#if defined(RTEMS_MULTIPROCESSING)
25#include <rtems/score/mpci.h>
26#endif
27#include <rtems/rtems/status.h>
28#include <rtems/rtems/attr.h>
29#include <rtems/rtems/message.h>
30#include <rtems/rtems/options.h>
31#include <rtems/rtems/support.h>
32
33/*PAGE
34 *
35 *  rtems_message_queue_get_number_pending
36 *
37 *  This directive returns the number of messages pending.
38 *
39 *  Input parameters:
40 *    id    - queue id
41 *    count - return area for count
42 *
43 *  Output parameters:
44 *    count             - number of messages removed ( 0 = empty queue )
45 *    RTEMS_SUCCESSFUL - if successful
46 *    error code        - if unsuccessful
47 */
48
49rtems_status_code rtems_message_queue_get_number_pending(
50  Objects_Id  id,
51  unsigned32 *count
52)
53{
54  register Message_queue_Control *the_message_queue;
55  Objects_Locations               location;
56
57  the_message_queue = _Message_queue_Get( id, &location );
58  switch ( location ) {
59    case OBJECTS_REMOTE:
60#if defined(RTEMS_MULTIPROCESSING)
61      _Thread_Executing->Wait.return_argument = count;
62
63      return _Message_queue_MP_Send_request_packet(
64          MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST,
65          id,
66          0,                               /* buffer not used */
67          0,                               /* size */
68          0,                               /* option_set not used */
69          MPCI_DEFAULT_TIMEOUT
70        );
71#endif
72
73    case OBJECTS_ERROR:
74      return RTEMS_INVALID_ID;
75
76    case OBJECTS_LOCAL:
77      *count = the_message_queue->message_queue.number_of_pending_messages;
78      _Thread_Enable_dispatch();
79      return RTEMS_SUCCESSFUL;
80  }
81
82  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
83}
Note: See TracBrowser for help on using the repository browser.