forked from Imagelibrary/rtems
2009-09-13 Joel Sherrill <joel.sherrill@oarcorp.com>
* score/inline/rtems/score/coremsg.inl, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c: Add wrappers for accessing message priority. Since these are empty when priority-based message queues are disabled, this eliminates some of the conditionals.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2009-09-13 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
|
* score/inline/rtems/score/coremsg.inl, score/src/coremsg.c,
|
||||||
|
score/src/coremsgbroadcast.c, score/src/coremsginsert.c,
|
||||||
|
score/src/coremsgseize.c, score/src/coremsgsubmit.c: Add wrappers for
|
||||||
|
accessing message priority. Since these are empty when priority-based
|
||||||
|
message queues are disabled, this eliminates some of the
|
||||||
|
conditionals.
|
||||||
|
|
||||||
2009-09-12 Joel Sherrill <joel.sherrill@oarcorp.com>
|
2009-09-12 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
* score/src/coremsgseize.c: Fix typo.
|
* score/src/coremsgseize.c: Fix typo.
|
||||||
|
|||||||
@@ -119,13 +119,44 @@ _CORE_message_queue_Allocate_message_buffer (
|
|||||||
* message buffer chain.
|
* message buffer chain.
|
||||||
*/
|
*/
|
||||||
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
|
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
|
||||||
CORE_message_queue_Control *the_message_queue,
|
CORE_message_queue_Control *the_message_queue,
|
||||||
CORE_message_queue_Buffer_control *the_message
|
CORE_message_queue_Buffer_control *the_message
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node );
|
_Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns the priority of @a the_message.
|
||||||
|
*
|
||||||
|
* NOTE: It encapsulates the optional behavior that message priority is
|
||||||
|
* disabled if no API requires it.
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE int _CORE_message_queue_Get_message_priority (
|
||||||
|
CORE_message_queue_Buffer_control *the_message
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
||||||
|
return the_message->priority;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function sets the priority of @a the_message.
|
||||||
|
*
|
||||||
|
* NOTE: It encapsulates the optional behavior that message priority is
|
||||||
|
* disabled if no API requires it.
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_message_priority (
|
||||||
|
CORE_message_queue_Buffer_control *the_message,
|
||||||
|
int priority
|
||||||
|
)
|
||||||
|
{
|
||||||
|
the_message->priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function removes the first message from the_message_queue
|
* This function removes the first message from the_message_queue
|
||||||
* and returns a pointer to it.
|
* and returns a pointer to it.
|
||||||
@@ -202,23 +233,24 @@ RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_null (
|
|||||||
{
|
{
|
||||||
return (the_message_queue->notify_handler != NULL);
|
return (the_message_queue->notify_handler != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This routine initializes the notification information for
|
|
||||||
* @a the_message_queue.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify (
|
|
||||||
CORE_message_queue_Control *the_message_queue,
|
|
||||||
CORE_message_queue_Notify_Handler the_handler,
|
|
||||||
void *the_argument
|
|
||||||
)
|
|
||||||
{
|
|
||||||
the_message_queue->notify_handler = the_handler;
|
|
||||||
the_message_queue->notify_argument = the_argument;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This routine initializes the notification information for
|
||||||
|
* @a the_message_queue.
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify (
|
||||||
|
CORE_message_queue_Control *the_message_queue,
|
||||||
|
CORE_message_queue_Notify_Handler the_handler,
|
||||||
|
void *the_argument
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
|
||||||
|
the_message_queue->notify_handler = the_handler;
|
||||||
|
the_message_queue->notify_argument = the_argument;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* This core object provides task synchronization and communication functions
|
* This core object provides task synchronization and communication functions
|
||||||
* via messages passed to queue objects.
|
* via messages passed to queue objects.
|
||||||
*
|
*
|
||||||
* COPYRIGHT (c) 1989-1999.
|
* COPYRIGHT (c) 1989-2009.
|
||||||
* On-Line Applications Research Corporation (OAR).
|
* On-Line Applications Research Corporation (OAR).
|
||||||
*
|
*
|
||||||
* The license and distribution terms for this file may be
|
* The license and distribution terms for this file may be
|
||||||
@@ -30,8 +30,7 @@
|
|||||||
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
||||||
#include <rtems/score/wkspace.h>
|
#include <rtems/score/wkspace.h>
|
||||||
|
|
||||||
/*PAGE
|
/*
|
||||||
*
|
|
||||||
* _CORE_message_queue_Initialize
|
* _CORE_message_queue_Initialize
|
||||||
*
|
*
|
||||||
* This routine initializes a newly created message queue based on the
|
* This routine initializes a newly created message queue based on the
|
||||||
@@ -62,19 +61,16 @@ bool _CORE_message_queue_Initialize(
|
|||||||
the_message_queue->maximum_pending_messages = maximum_pending_messages;
|
the_message_queue->maximum_pending_messages = maximum_pending_messages;
|
||||||
the_message_queue->number_of_pending_messages = 0;
|
the_message_queue->number_of_pending_messages = 0;
|
||||||
the_message_queue->maximum_message_size = maximum_message_size;
|
the_message_queue->maximum_message_size = maximum_message_size;
|
||||||
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
|
_CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
|
||||||
_CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Round size up to multiple of a pointer for chain init and
|
* Round size up to multiple of a pointer for chain init and
|
||||||
* check for overflow on adding overhead to each message.
|
* check for overflow on adding overhead to each message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
allocated_message_size = maximum_message_size;
|
allocated_message_size = maximum_message_size;
|
||||||
if (allocated_message_size & (sizeof(uint32_t) - 1)) {
|
if (allocated_message_size & (sizeof(uint32_t) - 1)) {
|
||||||
allocated_message_size += sizeof(uint32_t);
|
allocated_message_size += sizeof(uint32_t);
|
||||||
allocated_message_size &= ~(sizeof(uint32_t) - 1);
|
allocated_message_size &= ~(sizeof(uint32_t) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allocated_message_size < maximum_message_size)
|
if (allocated_message_size < maximum_message_size)
|
||||||
|
|||||||
@@ -55,13 +55,13 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
|
|||||||
CORE_message_queue_Control *the_message_queue,
|
CORE_message_queue_Control *the_message_queue,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
size_t size,
|
size_t size,
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
Objects_Id id,
|
Objects_Id id,
|
||||||
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
|
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
|
||||||
#else
|
#else
|
||||||
Objects_Id id __attribute__((unused)),
|
Objects_Id id __attribute__((unused)),
|
||||||
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)),
|
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)),
|
||||||
#endif
|
#endif
|
||||||
uint32_t *count
|
uint32_t *count
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -91,9 +91,9 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
|
|||||||
* There must be no pending messages if there is a thread waiting to
|
* There must be no pending messages if there is a thread waiting to
|
||||||
* receive a message.
|
* receive a message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
number_broadcasted = 0;
|
number_broadcasted = 0;
|
||||||
while ((the_thread = _Thread_queue_Dequeue(&the_message_queue->Wait_queue))) {
|
while ((the_thread =
|
||||||
|
_Thread_queue_Dequeue(&the_message_queue->Wait_queue) != NULL)) {
|
||||||
waitp = &the_thread->Wait;
|
waitp = &the_thread->Wait;
|
||||||
number_broadcasted += 1;
|
number_broadcasted += 1;
|
||||||
|
|
||||||
@@ -105,10 +105,10 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
|
|||||||
|
|
||||||
*(size_t *) the_thread->Wait.return_argument = size;
|
*(size_t *) the_thread->Wait.return_argument = size;
|
||||||
|
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
|
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
|
||||||
(*api_message_queue_mp_support) ( the_thread, id );
|
(*api_message_queue_mp_support) ( the_thread, id );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
*count = number_broadcasted;
|
*count = number_broadcasted;
|
||||||
|
|||||||
@@ -65,9 +65,7 @@ void _CORE_message_queue_Insert_message(
|
|||||||
#define SET_NOTIFY()
|
#define SET_NOTIFY()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
_CORE_message_queue_Set_message_priority( the_message, submit_type );
|
||||||
the_message->priority = submit_type;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
||||||
_ISR_Disable( level );
|
_ISR_Disable( level );
|
||||||
@@ -95,14 +93,19 @@ void _CORE_message_queue_Insert_message(
|
|||||||
CORE_message_queue_Buffer_control *this_message;
|
CORE_message_queue_Buffer_control *this_message;
|
||||||
Chain_Node *the_node;
|
Chain_Node *the_node;
|
||||||
Chain_Control *the_header;
|
Chain_Control *the_header;
|
||||||
|
int the_priority;
|
||||||
|
|
||||||
|
the_priority = _CORE_message_queue_Get_message_priority(the_message);
|
||||||
the_header = &the_message_queue->Pending_messages;
|
the_header = &the_message_queue->Pending_messages;
|
||||||
the_node = the_header->first;
|
the_node = the_header->first;
|
||||||
while ( !_Chain_Is_tail( the_header, the_node ) ) {
|
while ( !_Chain_Is_tail( the_header, the_node ) ) {
|
||||||
|
int this_priority;
|
||||||
|
|
||||||
this_message = (CORE_message_queue_Buffer_control *) the_node;
|
this_message = (CORE_message_queue_Buffer_control *) the_node;
|
||||||
|
|
||||||
if ( this_message->priority <= the_message->priority ) {
|
this_priority = _CORE_message_queue_Get_message_priority(this_message);
|
||||||
|
|
||||||
|
if ( this_priority <= the_priority ) {
|
||||||
the_node = the_node->next;
|
the_node = the_node->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,16 +78,20 @@ void _CORE_message_queue_Seize(
|
|||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
|
|
||||||
*size_p = the_message->Contents.size;
|
*size_p = the_message->Contents.size;
|
||||||
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
_Thread_Executing->Wait.count =
|
||||||
_Thread_Executing->Wait.count = the_message->priority;
|
_CORE_message_queue_Get_message_priority( the_message );
|
||||||
#endif
|
_CORE_message_queue_Copy_buffer(
|
||||||
_CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size_p);
|
the_message->Contents.buffer,
|
||||||
|
buffer,
|
||||||
|
*size_p
|
||||||
|
);
|
||||||
|
|
||||||
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
|
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
|
||||||
/*
|
/*
|
||||||
* There is not an API with blocking sends enabled. So return immediately.
|
* There is not an API with blocking sends enabled.
|
||||||
|
* So return immediately.
|
||||||
*/
|
*/
|
||||||
_CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
|
_CORE_message_queue_Free_message_buffer(the_message_queue, the_message);
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
@@ -102,7 +106,10 @@ void _CORE_message_queue_Seize(
|
|||||||
*/
|
*/
|
||||||
the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
|
the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
|
||||||
if ( !the_thread ) {
|
if ( !the_thread ) {
|
||||||
_CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
|
_CORE_message_queue_Free_message_buffer(
|
||||||
|
the_message_queue,
|
||||||
|
the_message
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,9 +118,10 @@ void _CORE_message_queue_Seize(
|
|||||||
* puts the messages in the message queue on behalf of the
|
* puts the messages in the message queue on behalf of the
|
||||||
* waiting task.
|
* waiting task.
|
||||||
*/
|
*/
|
||||||
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
_CORE_message_queue_Set_message_priority(
|
||||||
the_message->priority = the_thread->Wait.count;
|
the_message,
|
||||||
#endif
|
the_thread->Wait.count
|
||||||
|
);
|
||||||
the_message->Contents.size = (size_t) the_thread->Wait.option;
|
the_message->Contents.size = (size_t) the_thread->Wait.option;
|
||||||
_CORE_message_queue_Copy_buffer(
|
_CORE_message_queue_Copy_buffer(
|
||||||
the_thread->Wait.return_argument_second.immutable_object,
|
the_thread->Wait.return_argument_second.immutable_object,
|
||||||
@@ -124,11 +132,7 @@ void _CORE_message_queue_Seize(
|
|||||||
_CORE_message_queue_Insert_message(
|
_CORE_message_queue_Insert_message(
|
||||||
the_message_queue,
|
the_message_queue,
|
||||||
the_message,
|
the_message,
|
||||||
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
_CORE_message_queue_Get_message_priority( the_message )
|
||||||
the_message->priority
|
|
||||||
#else
|
|
||||||
0
|
|
||||||
#endif
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,11 +59,12 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
|
|||||||
const void *buffer,
|
const void *buffer,
|
||||||
size_t size,
|
size_t size,
|
||||||
Objects_Id id,
|
Objects_Id id,
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
|
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
|
||||||
#else
|
#else
|
||||||
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)),
|
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)),
|
||||||
#endif
|
#else
|
||||||
|
#endif
|
||||||
CORE_message_queue_Submit_types submit_type,
|
CORE_message_queue_Submit_types submit_type,
|
||||||
bool wait,
|
bool wait,
|
||||||
Watchdog_Interval timeout
|
Watchdog_Interval timeout
|
||||||
@@ -90,10 +91,10 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
|
|||||||
*(size_t *) the_thread->Wait.return_argument = size;
|
*(size_t *) the_thread->Wait.return_argument = size;
|
||||||
the_thread->Wait.count = submit_type;
|
the_thread->Wait.count = submit_type;
|
||||||
|
|
||||||
#if defined(RTEMS_MULTIPROCESSING)
|
#if defined(RTEMS_MULTIPROCESSING)
|
||||||
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
|
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
|
||||||
(*api_message_queue_mp_support) ( the_thread, id );
|
(*api_message_queue_mp_support) ( the_thread, id );
|
||||||
#endif
|
#endif
|
||||||
return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
|
return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,9 +124,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
|
|||||||
size
|
size
|
||||||
);
|
);
|
||||||
the_message->Contents.size = size;
|
the_message->Contents.size = size;
|
||||||
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
_CORE_message_queue_Set_message_priority( the_message, submit_type );
|
||||||
the_message->priority = submit_type;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_CORE_message_queue_Insert_message(
|
_CORE_message_queue_Insert_message(
|
||||||
the_message_queue,
|
the_message_queue,
|
||||||
|
|||||||
Reference in New Issue
Block a user