RTEMS
coremsginsert.c
Go to the documentation of this file.
1 
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.org/license/LICENSE.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
23 
24 #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
25 static bool _CORE_message_queue_Order(
26  const void *left,
27  const Chain_Node *right
28 )
29 {
30  const int *left_priority;
31  const CORE_message_queue_Buffer *right_message;
32 
33  left_priority = (const int *) left;
34  right_message = (const CORE_message_queue_Buffer *) right;
35 
36  return *left_priority <
38 }
39 #endif
40 
42  CORE_message_queue_Control *the_message_queue,
43  CORE_message_queue_Buffer *the_message,
44  const void *content_source,
45  size_t content_size,
47 )
48 {
49  Chain_Control *pending_messages;
50 
51  the_message->size = content_size;
52 
54  content_source,
55  the_message->buffer,
56  content_size
57  );
58 
59 #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
60  the_message->priority = submit_type;
61 #endif
62 
63  pending_messages = &the_message_queue->Pending_messages;
64  ++the_message_queue->number_of_pending_messages;
65 
66  if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST ) {
67  _Chain_Append_unprotected( pending_messages, &the_message->Node );
68 #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
69  } else if ( submit_type != CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
70  int priority;
71 
72  priority = _CORE_message_queue_Get_message_priority( the_message );
74  pending_messages,
75  &the_message->Node,
76  &priority,
77  _CORE_message_queue_Order
78  );
79 #endif
80  } else {
81  _Chain_Prepend_unprotected( pending_messages, &the_message->Node );
82  }
83 }
Inlined Routines in the Core Message Handler.
int CORE_message_queue_Submit_types
The modes in which a message may be submitted to a message queue.
Definition: coremsgimpl.h:69
static __inline__ void _CORE_message_queue_Copy_buffer(const void *source, void *destination, size_t size)
Copies the source message buffer to the destination message buffer.
Definition: coremsgimpl.h:464
uint32_t number_of_pending_messages
Definition: coremsg.h:113
static __inline__ void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
void _CORE_message_queue_Insert_message(CORE_message_queue_Control *the_message_queue, CORE_message_queue_Buffer *the_message, const void *content_source, size_t content_size, CORE_message_queue_Submit_types submit_type)
Inserts a message into the message queue.
Definition: coremsginsert.c:41
#define CORE_MESSAGE_QUEUE_SEND_REQUEST
Used when appending messages onto a message queue.
Definition: coremsgimpl.h:49
size_t size
This member defines the size of this message.
Definition: coremsgbuffer.h:71
static __inline__ void _Chain_Prepend_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepends a node (unprotected).
Definition: chainimpl.h:732
size_t buffer[RTEMS_ZERO_LENGTH_ARRAY]
This member contains the actual message.
Definition: coremsgbuffer.h:87
static __inline__ int _CORE_message_queue_Get_message_priority(const CORE_message_queue_Buffer *the_message)
Gets message priority.
Definition: coremsgimpl.h:523
Chain_Control Pending_messages
Definition: coremsg.h:121
#define CORE_MESSAGE_QUEUE_URGENT_REQUEST
Used when prepending messages onto a message queue.
Definition: coremsgimpl.h:57
The structure is used to organize message buffers of a message queue.
Definition: coremsgbuffer.h:63
int priority
This member defines the priority of this message.
Definition: coremsgbuffer.h:75
Control block used to manage each message queue.
Definition: coremsg.h:96
static __inline__ void _Chain_Insert_ordered_unprotected(Chain_Control *the_chain, Chain_Node *to_insert, const void *left, Chain_Node_order order)
Inserts a node into the chain according to the order relation.
Definition: chainimpl.h:864
Chain_Node Node
This member is used to enqueue the buffer in the pending or free buffer queue of a message queue...
Definition: coremsgbuffer.h:68