2009-09-11 Joel Sherrill <joel.sherrill@OARcorp.com>

* score/include/rtems/score/coremsg.h,
	score/inline/rtems/score/coremsg.inl, score/src/coremsg.c,
	score/src/coremsginsert.c, score/src/coremsgseize.c,
	score/src/coremsgsubmit.c, score/src/objectnametoidstring.c: Disable
	the Core Message Queue features of notification, priority messages,
	and blocking sends when no API requires them.
This commit is contained in:
Joel Sherrill
2009-09-11 20:00:30 +00:00
parent b09423368b
commit 507d38261d
8 changed files with 225 additions and 171 deletions

View File

@@ -1,3 +1,12 @@
2009-09-11 Joel Sherrill <joel.sherrill@OARcorp.com>
* score/include/rtems/score/coremsg.h,
score/inline/rtems/score/coremsg.inl, score/src/coremsg.c,
score/src/coremsginsert.c, score/src/coremsgseize.c,
score/src/coremsgsubmit.c, score/src/objectnametoidstring.c: Disable
the Core Message Queue features of notification, priority messages,
and blocking sends when no API requires them.
2009-09-11 Joel Sherrill <joel.sherrill@OARcorp.com>
* score/include/rtems/score/thread.h, score/src/threadhandler.c,

View File

@@ -6,7 +6,7 @@
*/
/*
* COPYRIGHT (c) 1989-2007.
* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -33,6 +33,18 @@
#include <rtems/score/priority.h>
#include <rtems/score/watchdog.h>
#if defined(RTEMS_POSIX_API)
#define RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY
#endif
#if defined(RTEMS_POSIX_API)
#define RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION
#endif
#if defined(RTEMS_POSIX_API)
#define RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND
#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -73,8 +85,10 @@ typedef struct {
typedef struct {
/** This element allows this structure to be placed on chains. */
Chain_Node Node;
/** This field is the priority of this message. */
int priority;
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
/** This field is the priority of this message. */
int priority;
#endif
/** This field points to the contents of the message. */
CORE_message_queue_Buffer Contents;
} CORE_message_queue_Buffer_control;
@@ -86,9 +100,9 @@ typedef struct {
* for a message queue.
*/
typedef enum {
/** This value indicates that pending messages are in FIFO order. */
/** This value indicates that blocking tasks are in FIFO order. */
CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
/** This value indicates that pending messages are in priority order. */
/** This value indicates that blocking tasks are in priority order. */
CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY
} CORE_message_queue_Disciplines;
@@ -167,14 +181,16 @@ typedef struct {
CORE_message_queue_Disciplines discipline;
} CORE_message_queue_Attributes;
/**
* @brief Message Queue Notification Callback Prototype
*
* The following defines the type for a Notification handler. A notification
* handler is invoked when the message queue makes a 0->1 transition on
* pending messages.
*/
typedef void (*CORE_message_queue_Notify_Handler)( void * );
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
/**
* @brief Message Queue Notification Callback Prototype
*
* The following defines the type for a Notification handler. A
* notification handler is invoked when the message queue makes a
* 0->1 transition on pending messages.
*/
typedef void (*CORE_message_queue_Notify_Handler)( void * );
#endif
/**
* @brief Core Message Queue Control Structure
@@ -211,12 +227,14 @@ typedef struct {
* as part of destroying it.
*/
CORE_message_queue_Buffer *message_buffers;
/** This is the routine invoked when the message queue transitions
* from zero (0) messages pending to one (1) message pending.
*/
CORE_message_queue_Notify_Handler notify_handler;
/** This field is the argument passed to the @ref notify_argument. */
void *notify_argument;
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
/** This is the routine invoked when the message queue transitions
* from zero (0) messages pending to one (1) message pending.
*/
CORE_message_queue_Notify_Handler notify_handler;
/** This field is the argument passed to the @ref notify_argument. */
void *notify_argument;
#endif
/** This chain is the set of inactive messages. A message is inactive
* when it does not contain a pending message.
*/

View File

@@ -6,7 +6,7 @@
*/
/*
* COPYRIGHT (c) 1989-2004.
* COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -33,7 +33,6 @@
/**
* This routine sends a message to the end of the specified message queue.
*/
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
CORE_message_queue_Control *the_message_queue,
const void *buffer,
@@ -63,7 +62,6 @@ RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
/**
* This routine sends a message to the front of the specified message queue.
*/
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
CORE_message_queue_Control *the_message_queue,
const void *buffer,
@@ -94,7 +92,6 @@ RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
* This routine copies the contents of the source message buffer
* to the destination message buffer.
*/
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer (
const void *source,
void *destination,
@@ -108,7 +105,6 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer (
* This function allocates a message buffer from the inactive
* message buffer chain.
*/
RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer_control *
_CORE_message_queue_Allocate_message_buffer (
CORE_message_queue_Control *the_message_queue
@@ -122,7 +118,6 @@ _CORE_message_queue_Allocate_message_buffer (
* This routine frees a message buffer to the inactive
* 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
@@ -135,7 +130,6 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
* This function removes the first message from the_message_queue
* and returns a pointer to it.
*/
RTEMS_INLINE_ROUTINE
CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message (
CORE_message_queue_Control *the_message_queue
@@ -149,19 +143,18 @@ RTEMS_INLINE_ROUTINE
* This function returns true if the priority attribute is
* enabled in the attribute_set and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_priority(
CORE_message_queue_Attributes *the_attribute
)
{
return (the_attribute->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY);
return
(the_attribute->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY);
}
/**
* This routine places the_message at the rear of the outstanding
* messages on the_message_queue.
*/
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append_unprotected (
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Buffer_control *the_message
@@ -177,7 +170,6 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append_unprotected (
* This routine places the_message at the front of the outstanding
* messages on the_message_queue.
*/
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Prepend_unprotected (
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Buffer_control *the_message
@@ -192,7 +184,6 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Prepend_unprotected (
/**
* This function returns true if the_message_queue is true and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_null (
CORE_message_queue_Control *the_message_queue
)
@@ -200,31 +191,33 @@ RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_null (
return ( the_message_queue == NULL );
}
/**
* This function returns true if notification is enabled on this message
* queue and false otherwise.
*/
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
/**
* This function returns true if notification is enabled on this message
* queue and false otherwise.
*/
RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_notify_enabled (
CORE_message_queue_Control *the_message_queue
)
{
return (the_message_queue->notify_handler != NULL);
}
RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_notify_enabled (
CORE_message_queue_Control *the_message_queue
)
{
return (the_message_queue->notify_handler != NULL);
}
/**
* This routine initializes the notification information for
* @a the_message_queue.
*/
/**
* This routine initializes the notification information for 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;
}
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
/**@}*/

View File

@@ -62,7 +62,9 @@ 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;
_CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
_CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
#endif
/*
* Round size up to multiple of a pointer for chain init and

View File

@@ -56,59 +56,73 @@ void _CORE_message_queue_Insert_message(
)
{
ISR_Level level;
bool notify = false;
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
bool notify = false;
#define SET_NOTIFY() \
if ( the_message_queue->number_of_pending_messages == 0 )
notify = true;
#else
#define SET_NOTIFY()
#endif
the_message->priority = submit_type;
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
the_message->priority = submit_type;
#endif
switch ( submit_type ) {
case CORE_MESSAGE_QUEUE_SEND_REQUEST:
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
_ISR_Disable( level );
SET_NOTIFY();
the_message_queue->number_of_pending_messages++;
if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST )
_CORE_message_queue_Append_unprotected(the_message_queue, the_message);
else
_CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
_ISR_Enable( level );
#else
if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST ) {
_ISR_Disable( level );
if ( the_message_queue->number_of_pending_messages++ == 0 )
notify = true;
SET_NOTIFY();
the_message_queue->number_of_pending_messages++;
_CORE_message_queue_Append_unprotected(the_message_queue, the_message);
_ISR_Enable( level );
break;
case CORE_MESSAGE_QUEUE_URGENT_REQUEST:
} else if ( submit_type == CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
_ISR_Disable( level );
if ( the_message_queue->number_of_pending_messages++ == 0 )
notify = true;
SET_NOTIFY();
the_message_queue->number_of_pending_messages++;
_CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
_ISR_Enable( level );
break;
default:
{
CORE_message_queue_Buffer_control *this_message;
Chain_Node *the_node;
Chain_Control *the_header;
} else {
CORE_message_queue_Buffer_control *this_message;
Chain_Node *the_node;
Chain_Control *the_header;
the_header = &the_message_queue->Pending_messages;
the_node = the_header->first;
while ( !_Chain_Is_tail( the_header, the_node ) ) {
the_header = &the_message_queue->Pending_messages;
the_node = the_header->first;
while ( !_Chain_Is_tail( the_header, the_node ) ) {
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 ) {
the_node = the_node->next;
continue;
}
break;
if ( this_message->priority <= the_message->priority ) {
the_node = the_node->next;
continue;
}
_ISR_Disable( level );
if ( the_message_queue->number_of_pending_messages++ == 0 )
notify = true;
_Chain_Insert_unprotected( the_node->previous, &the_message->Node );
_ISR_Enable( level );
break;
}
break;
}
_ISR_Disable( level );
SET_NOTIFY();
the_message_queue->number_of_pending_messages++;
_Chain_Insert_unprotected( the_node->previous, &the_message->Node );
_ISR_Enable( level );
}
#endif
/*
* According to POSIX, does this happen before or after the message
* is actually enqueued. It is logical to think afterwards, because
* the message is actually in the queue at this point.
*/
if ( notify && the_message_queue->notify_handler )
(*the_message_queue->notify_handler)( the_message_queue->notify_argument );
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
/*
* According to POSIX, does this happen before or after the message
* is actually enqueued. It is logical to think afterwards, because
* the message is actually in the queue at this point.
*/
if ( notify && the_message_queue->notify_handler )
(*the_message_queue->notify_handler)(the_message_queue->notify_argument);
#endif
}

View File

@@ -68,7 +68,6 @@ void _CORE_message_queue_Seize(
ISR_Level level;
CORE_message_queue_Buffer_control *the_message;
Thread_Control *executing;
Thread_Control *the_thread;
executing = _Thread_Executing;
executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
@@ -79,43 +78,61 @@ void _CORE_message_queue_Seize(
_ISR_Enable( level );
*size_p = the_message->Contents.size;
_Thread_Executing->Wait.count = the_message->priority;
#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);
/*
* There could be a thread waiting to send a message. If there
* is not, then we can go ahead and free the buffer.
*
* NOTE: If we note that the queue was not full before this receive,
* then we can avoid this dequeue.
*/
the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
if ( !the_thread ) {
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
/*
* There is not an API with blocking sends enabled. So return immediately.
*/
_CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
return;
#else
{
Thread_Control *the_thread;
/*
* There could be a thread waiting to send a message. If there
* is not, then we can go ahead and free the buffer.
*
* NOTE: If we note that the queue was not full before this receive,
* then we can avoid this dequeue.
*/
the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
if ( !the_thread ) {
_CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
return;
}
/*
* There was a thread waiting to send a message. This code
* 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
the_message->Contents.size = (size_t) the_thread->Wait.option;
_CORE_message_queue_Copy_buffer(
the_thread->Wait.return_argument_second.immutable_object,
the_message->Contents.buffer,
the_message->Contents.size
);
_CORE_message_queue_Insert_message(
the_message_queue,
the_message,
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
the_message->priority,
#else
0
#endif
);
return;
}
/*
* There was a thread waiting to send a message. This code
* puts the messages in the message queue on behalf of the
* waiting task.
*/
the_message->priority = 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,
the_message->Contents.buffer,
the_message->Contents.size
);
_CORE_message_queue_Insert_message(
the_message_queue,
the_message,
the_message->priority
);
return;
#endif
}
if ( !wait ) {

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
@@ -69,7 +69,6 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
Watchdog_Interval timeout
)
{
ISR_Level level;
CORE_message_queue_Buffer_control *the_message;
Thread_Control *the_thread;
@@ -80,7 +79,6 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
/*
* Is there a thread currently waiting on this message queue?
*/
if ( the_message_queue->number_of_pending_messages == 0 ) {
the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
if ( the_thread ) {
@@ -104,7 +102,6 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
* No one waiting on the message queue at this time, so attempt to
* queue the message up for a future receive.
*/
if ( the_message_queue->number_of_pending_messages <
the_message_queue->maximum_pending_messages ) {
@@ -126,7 +123,9 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
size
);
the_message->Contents.size = size;
the_message->priority = submit_type;
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
the_message->priority = submit_type;
#endif
_CORE_message_queue_Insert_message(
the_message_queue,
@@ -136,46 +135,48 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
}
/*
* No message buffers were available so we may need to return an
* overflow error or block the sender until the message is placed
* on the queue.
*/
if ( !wait ) {
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
}
#else
/*
* No message buffers were available so we may need to return an
* overflow error or block the sender until the message is placed
* on the queue.
*/
if ( !wait ) {
return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
}
/*
* Do NOT block on a send if the caller is in an ISR. It is
* deadly to block in an ISR.
*/
/*
* Do NOT block on a send if the caller is in an ISR. It is
* deadly to block in an ISR.
*/
if ( _ISR_Is_in_progress() ) {
return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
}
if ( _ISR_Is_in_progress() ) {
return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
}
/*
* WARNING!! executing should NOT be used prior to this point.
* Thus the unusual choice to open a new scope and declare
* it as a variable. Doing this emphasizes how dangerous it
* would be to use this variable prior to here.
*/
{
Thread_Control *executing = _Thread_Executing;
ISR_Level level;
/*
* WARNING!! executing should NOT be used prior to this point.
* Thus the unusual choice to open a new scope and declare
* it as a variable. Doing this emphasizes how dangerous it
* would be to use this variable prior to here.
*/
_ISR_Disable( level );
_Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
executing->Wait.queue = &the_message_queue->Wait_queue;
executing->Wait.id = id;
executing->Wait.return_argument_second.immutable_object = buffer;
executing->Wait.option = (uint32_t) size;
executing->Wait.count = submit_type;
_ISR_Enable( level );
{
Thread_Control *executing = _Thread_Executing;
_Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
}
_ISR_Disable( level );
_Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
executing->Wait.queue = &the_message_queue->Wait_queue;
executing->Wait.id = id;
executing->Wait.return_argument_second.immutable_object = buffer;
executing->Wait.option = (uint32_t) size;
executing->Wait.count = submit_type;
_ISR_Enable( level );
_Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
}
return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT;
return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT;
#endif
}

View File

@@ -16,7 +16,6 @@
#include "config.h"
#endif
#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
#include <string.h>
#include <rtems/system.h>
@@ -31,6 +30,7 @@
#include <rtems/score/sysstate.h>
#include <rtems/score/isr.h>
#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
/*PAGE
*
* _Objects_Name_to_id_string