source: rtems/cpukit/score/src/coremsginsert.c @ 4fc370e

4.115
Last change on this file since 4fc370e was f7f1d77, checked in by Alex Ivanov <alexivanov97@…>, on 11/28/12 at 14:11:31

score misc: Clean up Doxygen (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.
https://google-melange.appspot.com/gci/task/view/google/gci2012/7978208

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief Insert a Message into the Message Queue
5 * @ingroup ScoreMessageQueue
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2005.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/chain.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/object.h>
25#include <rtems/score/coremsg.h>
26#include <rtems/score/states.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/wkspace.h>
29
30void _CORE_message_queue_Insert_message(
31  CORE_message_queue_Control        *the_message_queue,
32  CORE_message_queue_Buffer_control *the_message,
33  CORE_message_queue_Submit_types    submit_type
34)
35{
36  ISR_Level  level;
37  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
38    bool    notify = false;
39    #define SET_NOTIFY() \
40      do { \
41        if ( the_message_queue->number_of_pending_messages == 0 ) \
42          notify = true; \
43      } while (0)
44  #else
45    #define SET_NOTIFY()
46  #endif
47
48  _CORE_message_queue_Set_message_priority( the_message, submit_type );
49
50  #if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
51    _ISR_Disable( level );
52      SET_NOTIFY();
53      the_message_queue->number_of_pending_messages++;
54      if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST )
55        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
56      else
57        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
58    _ISR_Enable( level );
59  #else
60    if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST ) {
61      _ISR_Disable( level );
62        SET_NOTIFY();
63        the_message_queue->number_of_pending_messages++;
64        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
65      _ISR_Enable( level );
66    } else if ( submit_type == CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
67      _ISR_Disable( level );
68        SET_NOTIFY();
69        the_message_queue->number_of_pending_messages++;
70        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
71      _ISR_Enable( level );
72    } else {
73      CORE_message_queue_Buffer_control *this_message;
74      Chain_Node                        *the_node;
75      Chain_Control                     *the_header;
76      int                                the_priority;
77
78      the_priority = _CORE_message_queue_Get_message_priority(the_message);
79      the_header = &the_message_queue->Pending_messages;
80      the_node = _Chain_First( the_header );
81      while ( !_Chain_Is_tail( the_header, the_node ) ) {
82        int this_priority;
83
84        this_message = (CORE_message_queue_Buffer_control *) the_node;
85
86        this_priority = _CORE_message_queue_Get_message_priority(this_message);
87
88        if ( this_priority <= the_priority ) {
89          the_node = the_node->next;
90          continue;
91        }
92        break;
93      }
94      _ISR_Disable( level );
95        SET_NOTIFY();
96        the_message_queue->number_of_pending_messages++;
97        _Chain_Insert_unprotected( the_node->previous, &the_message->Node );
98      _ISR_Enable( level );
99    }
100  #endif
101
102  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
103    /*
104     *  According to POSIX, does this happen before or after the message
105     *  is actually enqueued.  It is logical to think afterwards, because
106     *  the message is actually in the queue at this point.
107     */
108    if ( notify && the_message_queue->notify_handler )
109      (*the_message_queue->notify_handler)(the_message_queue->notify_argument);
110  #endif
111}
Note: See TracBrowser for help on using the repository browser.