source: rtems/cpukit/score/src/coremsginsert.c @ f26145b

4.104.114.84.95
Last change on this file since f26145b was a8eed23, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/27/05 at 05:57:05

Include config.h.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 *  CORE Message Queue Handler
3 *
4 *  DESCRIPTION:
5 *
6 *  This package is the implementation of the CORE Message Queue Handler.
7 *  This core object provides task synchronization and communication functions
8 *  via messages passed to queue objects.
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems/system.h>
25#include <rtems/score/chain.h>
26#include <rtems/score/isr.h>
27#include <rtems/score/object.h>
28#include <rtems/score/coremsg.h>
29#include <rtems/score/states.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/wkspace.h>
32#if defined(RTEMS_MULTIPROCESSING)
33#include <rtems/score/mpci.h>
34#endif
35
36/*PAGE
37 *
38 *  _CORE_message_queue_Insert_message
39 *
40 *  This kernel routine inserts the specified message into the
41 *  message queue.  It is assumed that the message has been filled
42 *  in before this routine is called.
43 *
44 *  Input parameters:
45 *    the_message_queue - pointer to message queue
46 *    the_message       - message to insert
47 *    priority          - insert indication
48 *
49 *  Output parameters:  NONE
50 *
51 *  INTERRUPT LATENCY:
52 *    insert
53 */
54
55void _CORE_message_queue_Insert_message(
56  CORE_message_queue_Control        *the_message_queue,
57  CORE_message_queue_Buffer_control *the_message,
58  CORE_message_queue_Submit_types    submit_type
59)
60{
61  the_message_queue->number_of_pending_messages += 1;
62
63  the_message->priority = submit_type;
64
65  switch ( submit_type ) {
66    case CORE_MESSAGE_QUEUE_SEND_REQUEST:
67      _CORE_message_queue_Append( the_message_queue, the_message );
68      break;
69    case CORE_MESSAGE_QUEUE_URGENT_REQUEST:
70      _CORE_message_queue_Prepend( the_message_queue, the_message );
71      break;
72    default:
73      /* XXX interrupt critical section needs to be addressed */
74      {
75        CORE_message_queue_Buffer_control *this_message;
76        Chain_Node                        *the_node;
77        Chain_Control                     *the_header;
78
79        the_header = &the_message_queue->Pending_messages;
80        the_node = the_header->first;
81        while ( !_Chain_Is_tail( the_header, the_node ) ) {
82
83          this_message = (CORE_message_queue_Buffer_control *) the_node;
84
85          if ( this_message->priority <= the_message->priority ) {
86            the_node = the_node->next;
87            continue;
88          }
89
90          break;
91        }
92        _Chain_Insert( the_node->previous, &the_message->Node );
93      }
94      break;
95  }
96
97  /*
98   *  According to POSIX, does this happen before or after the message
99   *  is actually enqueued.  It is logical to think afterwards, because
100   *  the message is actually in the queue at this point.
101   */
102
103  if ( the_message_queue->number_of_pending_messages == 1 &&
104       the_message_queue->notify_handler )
105    (*the_message_queue->notify_handler)( the_message_queue->notify_argument );
106}
Note: See TracBrowser for help on using the repository browser.