source: rtems/cpukit/score/src/coremsginsert.c @ 469dc47

5
Last change on this file since 469dc47 was 7e66865e, checked in by Sebastian Huber <sebastian.huber@…>, on 04/29/16 at 09:05:36

score: Move message notification

Move message notification to end of critical section and delegate the
message queue release to the notification handler. It may do more
complex notification actions out of the critical section.

Update #2555.

  • Property mode set to 100644
File size: 2.1 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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/coremsgimpl.h>
22
23#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
24static bool _CORE_message_queue_Order(
25  const Chain_Node *left,
26  const Chain_Node *right
27)
28{
29   const CORE_message_queue_Buffer_control *left_message;
30   const CORE_message_queue_Buffer_control *right_message;
31
32   left_message = (const CORE_message_queue_Buffer_control *) left;
33   right_message = (const CORE_message_queue_Buffer_control *) right;
34
35   return _CORE_message_queue_Get_message_priority( left_message ) <
36     _CORE_message_queue_Get_message_priority( right_message );
37}
38#endif
39
40void _CORE_message_queue_Insert_message(
41  CORE_message_queue_Control        *the_message_queue,
42  CORE_message_queue_Buffer_control *the_message,
43  const void                        *content_source,
44  size_t                             content_size,
45  CORE_message_queue_Submit_types    submit_type
46)
47{
48  Chain_Control *pending_messages;
49
50  the_message->Contents.size = content_size;
51
52  _CORE_message_queue_Copy_buffer(
53    content_source,
54    the_message->Contents.buffer,
55    content_size
56  );
57
58#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
59  the_message->priority = submit_type;
60#endif
61
62  pending_messages = &the_message_queue->Pending_messages;
63  ++the_message_queue->number_of_pending_messages;
64
65  if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST ) {
66    _Chain_Append_unprotected( pending_messages, &the_message->Node );
67#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
68  } else  if ( submit_type != CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
69    _Chain_Insert_ordered_unprotected(
70      pending_messages,
71      &the_message->Node,
72      _CORE_message_queue_Order
73    );
74#endif
75  } else {
76    _Chain_Prepend_unprotected( pending_messages, &the_message->Node );
77  }
78}
Note: See TracBrowser for help on using the repository browser.