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:
Joel Sherrill
2009-09-13 16:05:14 +00:00
parent 302e4367bb
commit 939ba8162f
7 changed files with 113 additions and 70 deletions

View File

@@ -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>
* score/src/coremsgseize.c: Fix typo.

View File

@@ -119,13 +119,44 @@ _CORE_message_queue_Allocate_message_buffer (
* message buffer chain.
*/
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Buffer_control *the_message
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Buffer_control *the_message
)
{
_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
* and returns a pointer to it.
@@ -202,22 +233,23 @@ RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_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
/**
* 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
}
/**@}*/

View File

@@ -7,7 +7,7 @@
* This core object provides task synchronization and communication functions
* via messages passed to queue objects.
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -30,8 +30,7 @@
#include <rtems/score/thread.h>
#include <rtems/score/wkspace.h>
/*PAGE
*
/*
* _CORE_message_queue_Initialize
*
* 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->number_of_pending_messages = 0;
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 );
#endif
_CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
/*
* Round size up to multiple of a pointer for chain init and
* check for overflow on adding overhead to each message.
*/
allocated_message_size = maximum_message_size;
if (allocated_message_size & (sizeof(uint32_t) - 1)) {
allocated_message_size += sizeof(uint32_t);
allocated_message_size &= ~(sizeof(uint32_t) - 1);
allocated_message_size += sizeof(uint32_t);
allocated_message_size &= ~(sizeof(uint32_t) - 1);
}
if (allocated_message_size < maximum_message_size)

View File

@@ -55,13 +55,13 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
CORE_message_queue_Control *the_message_queue,
const void *buffer,
size_t size,
#if defined(RTEMS_MULTIPROCESSING)
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
#else
Objects_Id id __attribute__((unused)),
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)),
#endif
#if defined(RTEMS_MULTIPROCESSING)
Objects_Id id,
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
#else
Objects_Id id __attribute__((unused)),
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)),
#endif
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
* receive a message.
*/
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;
number_broadcasted += 1;
@@ -105,10 +105,10 @@ CORE_message_queue_Status _CORE_message_queue_Broadcast(
*(size_t *) the_thread->Wait.return_argument = size;
#if defined(RTEMS_MULTIPROCESSING)
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
(*api_message_queue_mp_support) ( the_thread, id );
#endif
#if defined(RTEMS_MULTIPROCESSING)
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
(*api_message_queue_mp_support) ( the_thread, id );
#endif
}
*count = number_broadcasted;

View File

@@ -65,9 +65,7 @@ void _CORE_message_queue_Insert_message(
#define SET_NOTIFY()
#endif
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
the_message->priority = submit_type;
#endif
_CORE_message_queue_Set_message_priority( the_message, submit_type );
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
_ISR_Disable( level );
@@ -95,14 +93,19 @@ void _CORE_message_queue_Insert_message(
CORE_message_queue_Buffer_control *this_message;
Chain_Node *the_node;
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_node = the_header->first;
while ( !_Chain_Is_tail( the_header, the_node ) ) {
int this_priority;
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;
continue;
}

View File

@@ -78,16 +78,20 @@ void _CORE_message_queue_Seize(
_ISR_Enable( level );
*size_p = the_message->Contents.size;
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
_Thread_Executing->Wait.count = the_message->priority;
#endif
_CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size_p);
_Thread_Executing->Wait.count =
_CORE_message_queue_Get_message_priority( the_message );
_CORE_message_queue_Copy_buffer(
the_message->Contents.buffer,
buffer,
*size_p
);
#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;
#else
{
@@ -102,7 +106,10 @@ void _CORE_message_queue_Seize(
*/
the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
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;
}
@@ -111,9 +118,10 @@ void _CORE_message_queue_Seize(
* puts the messages in the message queue on behalf of the
* waiting task.
*/
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
the_message->priority = the_thread->Wait.count;
#endif
_CORE_message_queue_Set_message_priority(
the_message,
the_thread->Wait.count
);
the_message->Contents.size = (size_t) the_thread->Wait.option;
_CORE_message_queue_Copy_buffer(
the_thread->Wait.return_argument_second.immutable_object,
@@ -124,11 +132,7 @@ void _CORE_message_queue_Seize(
_CORE_message_queue_Insert_message(
the_message_queue,
the_message,
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
the_message->priority
#else
0
#endif
_CORE_message_queue_Get_message_priority( the_message )
);
return;
}

View File

@@ -59,11 +59,12 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
const void *buffer,
size_t size,
Objects_Id id,
#if defined(RTEMS_MULTIPROCESSING)
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
#else
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)),
#endif
#if defined(RTEMS_MULTIPROCESSING)
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support,
#else
CORE_message_queue_API_mp_support_callout api_message_queue_mp_support __attribute__((unused)),
#else
#endif
CORE_message_queue_Submit_types submit_type,
bool wait,
Watchdog_Interval timeout
@@ -90,10 +91,10 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
*(size_t *) the_thread->Wait.return_argument = size;
the_thread->Wait.count = submit_type;
#if defined(RTEMS_MULTIPROCESSING)
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
(*api_message_queue_mp_support) ( the_thread, id );
#endif
#if defined(RTEMS_MULTIPROCESSING)
if ( !_Objects_Is_local_id( the_thread->Object.id ) )
(*api_message_queue_mp_support) ( the_thread, id );
#endif
return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
}
}
@@ -123,9 +124,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
size
);
the_message->Contents.size = size;
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
the_message->priority = submit_type;
#endif
_CORE_message_queue_Set_message_priority( the_message, submit_type );
_CORE_message_queue_Insert_message(
the_message_queue,