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

4.104.114.95
Last change on this file since b3836ce was b3836ce, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 5, 2008 at 9:54:20 PM

2008-09-05 Joel Sherrill <joel.sherrill@…>

  • score/src/corebarrier.c, score/src/corebarrierrelease.c, score/src/corebarrierwait.c, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsgclose.c, score/src/coremsgflush.c, score/src/coremsgflushsupp.c, score/src/coremsgflushwait.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/corerwlock.c, score/src/coresem.c, score/src/coresemflush.c, score/src/coresemseize.c, score/src/coresemsurrender.c, score/src/corespinlock.c, score/src/threadblockingoperationcancel.c, score/src/threadqenqueue.c: Remove unnecessary include of mpci.h.
  • Property mode set to 100644
File size: 3.3 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-2005.
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
33/*PAGE
34 *
35 *  _CORE_message_queue_Insert_message
36 *
37 *  This kernel routine inserts the specified message into the
38 *  message queue.  It is assumed that the message has been filled
39 *  in before this routine is called.
40 *
41 *  Input parameters:
42 *    the_message_queue - pointer to message queue
43 *    the_message       - message to insert
44 *    priority          - insert indication
45 *
46 *  Output parameters:  NONE
47 *
48 *  INTERRUPT LATENCY:
49 *    insert
50 */
51
52void _CORE_message_queue_Insert_message(
53  CORE_message_queue_Control        *the_message_queue,
54  CORE_message_queue_Buffer_control *the_message,
55  CORE_message_queue_Submit_types    submit_type
56)
57{
58  ISR_Level  level;
59  bool       notify = false;
60
61  the_message->priority = submit_type;
62
63  switch ( submit_type ) {
64    case CORE_MESSAGE_QUEUE_SEND_REQUEST:
65      _ISR_Disable( level );
66        if ( the_message_queue->number_of_pending_messages++ == 0 )
67          notify = true;
68        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
69      _ISR_Enable( level );
70      break;
71    case CORE_MESSAGE_QUEUE_URGENT_REQUEST:
72      _ISR_Disable( level );
73        if ( the_message_queue->number_of_pending_messages++ == 0 )
74          notify = true;
75        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
76      _ISR_Enable( level );
77      break;
78    default:
79      {
80        CORE_message_queue_Buffer_control *this_message;
81        Chain_Node                        *the_node;
82        Chain_Control                     *the_header;
83
84        the_header = &the_message_queue->Pending_messages;
85        the_node = the_header->first;
86        while ( !_Chain_Is_tail( the_header, the_node ) ) {
87
88          this_message = (CORE_message_queue_Buffer_control *) the_node;
89
90          if ( this_message->priority <= the_message->priority ) {
91            the_node = the_node->next;
92            continue;
93          }
94
95          break;
96        }
97        _ISR_Disable( level );
98          if ( the_message_queue->number_of_pending_messages++ == 0 )
99            notify = true;
100          _Chain_Insert_unprotected( the_node->previous, &the_message->Node );
101        _ISR_Enable( level );
102      }
103      break;
104  }
105
106  /*
107   *  According to POSIX, does this happen before or after the message
108   *  is actually enqueued.  It is logical to think afterwards, because
109   *  the message is actually in the queue at this point.
110   */
111
112  if ( notify && the_message_queue->notify_handler )
113    (*the_message_queue->notify_handler)( the_message_queue->notify_argument );
114}
Note: See TracBrowser for help on using the repository browser.