source: rtems/cpukit/score/src/coremsginsert.c @ 507d382

4.104.115
Last change on this file since 507d382 was 507d382, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/09 at 20:00:30

2009-09-11 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/coremsg.h, score/inline/rtems/score/coremsg.inl, score/src/coremsg.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/objectnametoidstring.c: Disable the Core Message Queue features of notification, priority messages, and blocking sends when no API requires them.
  • Property mode set to 100644
File size: 3.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-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  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
60    bool    notify = false;
61    #define SET_NOTIFY() \
62      if ( the_message_queue->number_of_pending_messages == 0 )
63        notify = true;
64  #else
65    #define SET_NOTIFY()
66  #endif
67
68  #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
69    the_message->priority = submit_type;
70  #endif
71
72  #if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
73    _ISR_Disable( level );
74      SET_NOTIFY();
75      the_message_queue->number_of_pending_messages++;
76      if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST )
77        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
78      else
79        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
80    _ISR_Enable( level );
81  #else
82    if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST ) {
83      _ISR_Disable( level );
84        SET_NOTIFY();
85        the_message_queue->number_of_pending_messages++;
86        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
87      _ISR_Enable( level );
88    } else if ( submit_type == CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
89      _ISR_Disable( level );
90        SET_NOTIFY();
91        the_message_queue->number_of_pending_messages++;
92        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
93      _ISR_Enable( level );
94    } else {
95      CORE_message_queue_Buffer_control *this_message;
96      Chain_Node                        *the_node;
97      Chain_Control                     *the_header;
98
99      the_header = &the_message_queue->Pending_messages;
100      the_node = the_header->first;
101      while ( !_Chain_Is_tail( the_header, the_node ) ) {
102
103        this_message = (CORE_message_queue_Buffer_control *) the_node;
104
105        if ( this_message->priority <= the_message->priority ) {
106          the_node = the_node->next;
107          continue;
108        }
109        break;
110      }
111      _ISR_Disable( level );
112        SET_NOTIFY();
113        the_message_queue->number_of_pending_messages++;
114        _Chain_Insert_unprotected( the_node->previous, &the_message->Node );
115      _ISR_Enable( level );
116    }
117  #endif
118
119  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
120    /*
121     *  According to POSIX, does this happen before or after the message
122     *  is actually enqueued.  It is logical to think afterwards, because
123     *  the message is actually in the queue at this point.
124     */
125    if ( notify && the_message_queue->notify_handler )
126      (*the_message_queue->notify_handler)(the_message_queue->notify_argument);
127  #endif
128}
Note: See TracBrowser for help on using the repository browser.