OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [msgqgetnumberpending.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: msgqgetnumberpending.c,v 1.2 2001-09-27 11:59:19 chris Exp $
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
 
49
rtems_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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.