source: rtems/cpukit/score/src/coremsginsert.c @ 2d7ae960

4.115
Last change on this file since 2d7ae960 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 4.1 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
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/system.h>
23#include <rtems/score/chain.h>
24#include <rtems/score/isr.h>
25#include <rtems/score/object.h>
26#include <rtems/score/coremsg.h>
27#include <rtems/score/states.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/wkspace.h>
30
31/*
32 *  _CORE_message_queue_Insert_message
33 *
34 *  This kernel routine inserts the specified message into the
35 *  message queue.  It is assumed that the message has been filled
36 *  in before this routine is called.
37 *
38 *  Input parameters:
39 *    the_message_queue - pointer to message queue
40 *    the_message       - message to insert
41 *    priority          - insert indication
42 *
43 *  Output parameters:  NONE
44 *
45 *  INTERRUPT LATENCY:
46 *    insert
47 */
48
49void _CORE_message_queue_Insert_message(
50  CORE_message_queue_Control        *the_message_queue,
51  CORE_message_queue_Buffer_control *the_message,
52  CORE_message_queue_Submit_types    submit_type
53)
54{
55  ISR_Level  level;
56  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
57    bool    notify = false;
58    #define SET_NOTIFY() \
59      do { \
60        if ( the_message_queue->number_of_pending_messages == 0 ) \
61          notify = true; \
62      } while (0)
63  #else
64    #define SET_NOTIFY()
65  #endif
66
67  _CORE_message_queue_Set_message_priority( the_message, submit_type );
68
69  #if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
70    _ISR_Disable( level );
71      SET_NOTIFY();
72      the_message_queue->number_of_pending_messages++;
73      if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST )
74        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
75      else
76        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
77    _ISR_Enable( level );
78  #else
79    if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST ) {
80      _ISR_Disable( level );
81        SET_NOTIFY();
82        the_message_queue->number_of_pending_messages++;
83        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
84      _ISR_Enable( level );
85    } else if ( submit_type == CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
86      _ISR_Disable( level );
87        SET_NOTIFY();
88        the_message_queue->number_of_pending_messages++;
89        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
90      _ISR_Enable( level );
91    } else {
92      CORE_message_queue_Buffer_control *this_message;
93      Chain_Node                        *the_node;
94      Chain_Control                     *the_header;
95      int                                the_priority;
96
97      the_priority = _CORE_message_queue_Get_message_priority(the_message);
98      the_header = &the_message_queue->Pending_messages;
99      the_node = _Chain_First( the_header );
100      while ( !_Chain_Is_tail( the_header, the_node ) ) {
101        int this_priority;
102
103        this_message = (CORE_message_queue_Buffer_control *) the_node;
104
105        this_priority = _CORE_message_queue_Get_message_priority(this_message);
106
107        if ( this_priority <= the_priority ) {
108          the_node = the_node->next;
109          continue;
110        }
111        break;
112      }
113      _ISR_Disable( level );
114        SET_NOTIFY();
115        the_message_queue->number_of_pending_messages++;
116        _Chain_Insert_unprotected( the_node->previous, &the_message->Node );
117      _ISR_Enable( level );
118    }
119  #endif
120
121  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
122    /*
123     *  According to POSIX, does this happen before or after the message
124     *  is actually enqueued.  It is logical to think afterwards, because
125     *  the message is actually in the queue at this point.
126     */
127    if ( notify && the_message_queue->notify_handler )
128      (*the_message_queue->notify_handler)(the_message_queue->notify_argument);
129  #endif
130}
Note: See TracBrowser for help on using the repository browser.