source: rtems/cpukit/score/src/coremsginsert.c @ 7fa97181

Last change on this file since 7fa97181 was a6eef8b, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:52:48

2003-09-04 Joel Sherrill <joel@…>

  • apiext.c, chain.c, coremsg.c, coremsgbroadcast.c, coremsgclose.c, coremsgflush.c, coremsgflushsupp.c, coremsgflushwait.c, coremsginsert.c, coremsgseize.c, coremsgsubmit.c, coremutex.c, coremutexflush.c, coremutexseize.c, coremutexsurrender.c, coresem.c, coresemflush.c, coresemseize.c, coresemsurrender.c, coretod.c, coretodset.c, coretodtickle.c, coretodtoseconds.c, coretodvalidate.c, heap.c, heapallocate.c, heapextend.c, heapfree.c, heapgetinfo.c, heapsizeofuserarea.c, heapwalk.c, interr.c, isr.c, mpci.c, object.c, objectallocate.c, objectallocatebyindex.c, objectclearname.c, objectcomparenameraw.c, objectcomparenamestring.c, objectcopynameraw.c, objectcopynamestring.c, objectextendinformation.c, objectfree.c, objectget.c, objectgetbyindex.c, objectgetisr.c, objectgetnext.c, objectgetnoprotection.c, objectinitializeinformation.c, objectmp.c, objectnametoid.c, objectshrinkinformation.c, thread.c, threadchangepriority.c, threadclearstate.c, threadclose.c, threadcreateidle.c, threaddelayended.c, threaddispatch.c, threadevaluatemode.c, threadget.c, threadhandler.c, threadidlebody.c, threadinitialize.c, threadloadenv.c, threadmp.c, threadq.c, threadqdequeue.c, threadqdequeuefifo.c, threadqdequeuepriority.c, threadqenqueue.c, threadqenqueuefifo.c, threadqenqueuepriority.c, threadqextract.c, threadqextractfifo.c, threadqextractpriority.c, threadqextractwithproxy.c, threadqfirst.c, threadqfirstfifo.c, threadqfirstpriority.c, threadqflush.c, threadqtimeout.c, threadready.c, threadreset.c, threadresettimeslice.c, threadrestart.c, threadresume.c, threadrotatequeue.c, threadsetpriority.c, threadsetstate.c, threadsettransient.c, threadstackallocate.c, threadstackfree.c, threadstart.c, threadstartmultitasking.c, threadsuspend.c, threadtickletimeslice.c, threadyieldprocessor.c, userext.c, watchdog.c, watchdogadjust.c, watchdoginsert.c, watchdogremove.c, watchdogtickle.c, wkspace.c: URL for license changed.
  • Property mode set to 100644
File size: 2.9 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#include <rtems/system.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/score/coremsg.h>
25#include <rtems/score/states.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#if defined(RTEMS_MULTIPROCESSING)
29#include <rtems/score/mpci.h>
30#endif
31
32/*PAGE
33 *
34 *  _CORE_message_queue_Insert_message
35 *
36 *  This kernel routine inserts the specified message into the
37 *  message queue.  It is assumed that the message has been filled
38 *  in before this routine is called.
39 *
40 *  Input parameters:
41 *    the_message_queue - pointer to message queue
42 *    the_message       - message to insert
43 *    priority          - insert indication
44 *
45 *  Output parameters:  NONE
46 *
47 *  INTERRUPT LATENCY:
48 *    insert
49 */
50
51void _CORE_message_queue_Insert_message(
52  CORE_message_queue_Control        *the_message_queue,
53  CORE_message_queue_Buffer_control *the_message,
54  CORE_message_queue_Submit_types    submit_type
55)
56{
57  the_message_queue->number_of_pending_messages += 1;
58
59  the_message->priority = submit_type;
60
61  switch ( submit_type ) {
62    case CORE_MESSAGE_QUEUE_SEND_REQUEST:
63      _CORE_message_queue_Append( the_message_queue, the_message );
64      break;
65    case CORE_MESSAGE_QUEUE_URGENT_REQUEST:
66      _CORE_message_queue_Prepend( the_message_queue, the_message );
67      break;
68    default:
69      /* XXX interrupt critical section needs to be addressed */
70      {
71        CORE_message_queue_Buffer_control *this_message;
72        Chain_Node                        *the_node;
73        Chain_Control                     *the_header;
74
75        the_header = &the_message_queue->Pending_messages;
76        the_node = the_header->first;
77        while ( !_Chain_Is_tail( the_header, the_node ) ) {
78
79          this_message = (CORE_message_queue_Buffer_control *) the_node;
80
81          if ( this_message->priority <= the_message->priority ) {
82            the_node = the_node->next;
83            continue;
84          }
85
86          break;
87        }
88        _Chain_Insert( the_node->previous, &the_message->Node );
89      }
90      break;
91  }
92
93  /*
94   *  According to POSIX, does this happen before or after the message
95   *  is actually enqueued.  It is logical to think afterwards, because
96   *  the message is actually in the queue at this point.
97   */
98
99  if ( the_message_queue->number_of_pending_messages == 1 &&
100       the_message_queue->notify_handler )
101    (*the_message_queue->notify_handler)( the_message_queue->notify_argument );
102}
Note: See TracBrowser for help on using the repository browser.