source: rtems/cpukit/itron/src/ref_mbf.c @ 4bf1801

4.104.114.84.95
Last change on this file since 4bf1801 was 9d9a3dd, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/17/99 at 16:47:58

+ Updated copyright information.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  ITRON Message Buffer Manager
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#include <itron.h>
15
16#include <rtems/itron/msgbuffer.h>
17#include <rtems/itron/task.h>
18
19/*
20 *  ref_mbf - Reference Message Buffer Status
21 */
22
23ER ref_mbf(
24  T_RMBF *pk_rmbf,
25  ID      mbfid
26)
27{
28  ITRON_Message_buffer_Control      *the_message_buffer;
29  Objects_Locations                  location;
30  CORE_message_queue_Control        *the_core_msgq;
31       
32  if ( !pk_rmbf )
33    return E_PAR;   /* XXX check this error code */
34
35  the_message_buffer = _ITRON_Message_buffer_Get( mbfid, &location );
36  switch ( location ) {   
37  case OBJECTS_REMOTE:               /* Multiprocessing not supported */
38  case OBJECTS_ERROR:
39    return _ITRON_Message_buffer_Clarify_get_id_error( mbfid );
40 
41  case OBJECTS_LOCAL:
42    the_core_msgq = &the_message_buffer->message_queue;
43
44    /*
45     *  Fill in the size of message to be sent
46     */
47
48    if (the_core_msgq->number_of_pending_messages == 0) {
49      pk_rmbf->msgsz = 0;
50    } else {
51      pk_rmbf->msgsz = ((CORE_message_queue_Buffer_control *)
52        the_core_msgq->Pending_messages.first)->Contents.size;
53    }
54       
55    /*
56     *  Fill in the size of free buffer
57     */
58
59    pk_rmbf->frbufsz =
60      (the_core_msgq->maximum_pending_messages -
61       the_core_msgq->number_of_pending_messages) *
62       the_core_msgq->maximum_message_size;
63
64
65    /*
66     *  Fill in whether or not there is a waiting task
67     */
68
69    if ( !_Thread_queue_First(&the_core_msgq->Wait_queue ) )
70       pk_rmbf->wtsk = FALSE;
71    else
72       pk_rmbf->wtsk =  TRUE;
73
74    pk_rmbf->stsk = FALSE;
75    _Thread_Enable_dispatch();
76    return E_OK;
77  }   
78  return E_OK;
79}
Note: See TracBrowser for help on using the repository browser.