forked from Imagelibrary/rtems
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:
@@ -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>
|
2009-09-11 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||||
|
|
||||||
* score/include/rtems/score/thread.h, score/src/threadhandler.c,
|
* score/include/rtems/score/thread.h, score/src/threadhandler.c,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT (c) 1989-2007.
|
* 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
|
||||||
@@ -33,6 +33,18 @@
|
|||||||
#include <rtems/score/priority.h>
|
#include <rtems/score/priority.h>
|
||||||
#include <rtems/score/watchdog.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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -73,8 +85,10 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/** This element allows this structure to be placed on chains. */
|
/** This element allows this structure to be placed on chains. */
|
||||||
Chain_Node Node;
|
Chain_Node Node;
|
||||||
/** This field is the priority of this message. */
|
#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
||||||
int priority;
|
/** This field is the priority of this message. */
|
||||||
|
int priority;
|
||||||
|
#endif
|
||||||
/** This field points to the contents of the message. */
|
/** This field points to the contents of the message. */
|
||||||
CORE_message_queue_Buffer Contents;
|
CORE_message_queue_Buffer Contents;
|
||||||
} CORE_message_queue_Buffer_control;
|
} CORE_message_queue_Buffer_control;
|
||||||
@@ -86,9 +100,9 @@ typedef struct {
|
|||||||
* for a message queue.
|
* for a message queue.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
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,
|
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_PRIORITY
|
||||||
} CORE_message_queue_Disciplines;
|
} CORE_message_queue_Disciplines;
|
||||||
|
|
||||||
@@ -167,14 +181,16 @@ typedef struct {
|
|||||||
CORE_message_queue_Disciplines discipline;
|
CORE_message_queue_Disciplines discipline;
|
||||||
} CORE_message_queue_Attributes;
|
} CORE_message_queue_Attributes;
|
||||||
|
|
||||||
/**
|
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
|
||||||
* @brief Message Queue Notification Callback Prototype
|
/**
|
||||||
*
|
* @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
|
* The following defines the type for a Notification handler. A
|
||||||
* pending messages.
|
* notification handler is invoked when the message queue makes a
|
||||||
*/
|
* 0->1 transition on pending messages.
|
||||||
typedef void (*CORE_message_queue_Notify_Handler)( void * );
|
*/
|
||||||
|
typedef void (*CORE_message_queue_Notify_Handler)( void * );
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Core Message Queue Control Structure
|
* @brief Core Message Queue Control Structure
|
||||||
@@ -211,12 +227,14 @@ typedef struct {
|
|||||||
* as part of destroying it.
|
* as part of destroying it.
|
||||||
*/
|
*/
|
||||||
CORE_message_queue_Buffer *message_buffers;
|
CORE_message_queue_Buffer *message_buffers;
|
||||||
/** This is the routine invoked when the message queue transitions
|
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
|
||||||
* from zero (0) messages pending to one (1) message pending.
|
/** 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. */
|
CORE_message_queue_Notify_Handler notify_handler;
|
||||||
void *notify_argument;
|
/** 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
|
/** This chain is the set of inactive messages. A message is inactive
|
||||||
* when it does not contain a pending message.
|
* when it does not contain a pending message.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT (c) 1989-2004.
|
* 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
|
||||||
@@ -33,7 +33,6 @@
|
|||||||
/**
|
/**
|
||||||
* This routine sends a message to the end of the specified message queue.
|
* This routine sends a message to the end of the specified message queue.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
|
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
|
||||||
CORE_message_queue_Control *the_message_queue,
|
CORE_message_queue_Control *the_message_queue,
|
||||||
const void *buffer,
|
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.
|
* This routine sends a message to the front of the specified message queue.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
|
RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
|
||||||
CORE_message_queue_Control *the_message_queue,
|
CORE_message_queue_Control *the_message_queue,
|
||||||
const void *buffer,
|
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
|
* This routine copies the contents of the source message buffer
|
||||||
* to the destination message buffer.
|
* to the destination message buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer (
|
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer (
|
||||||
const void *source,
|
const void *source,
|
||||||
void *destination,
|
void *destination,
|
||||||
@@ -108,7 +105,6 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer (
|
|||||||
* This function allocates a message buffer from the inactive
|
* This function allocates a message buffer from the inactive
|
||||||
* message buffer chain.
|
* message buffer chain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer_control *
|
RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer_control *
|
||||||
_CORE_message_queue_Allocate_message_buffer (
|
_CORE_message_queue_Allocate_message_buffer (
|
||||||
CORE_message_queue_Control *the_message_queue
|
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
|
* This routine frees a message buffer to the inactive
|
||||||
* 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
|
||||||
@@ -135,7 +130,6 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE
|
RTEMS_INLINE_ROUTINE
|
||||||
CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message (
|
CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message (
|
||||||
CORE_message_queue_Control *the_message_queue
|
CORE_message_queue_Control *the_message_queue
|
||||||
@@ -149,19 +143,18 @@ RTEMS_INLINE_ROUTINE
|
|||||||
* This function returns true if the priority attribute is
|
* This function returns true if the priority attribute is
|
||||||
* enabled in the attribute_set and false otherwise.
|
* enabled in the attribute_set and false otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_priority(
|
RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_priority(
|
||||||
CORE_message_queue_Attributes *the_attribute
|
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
|
* This routine places the_message at the rear of the outstanding
|
||||||
* messages on the_message_queue.
|
* messages on the_message_queue.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append_unprotected (
|
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append_unprotected (
|
||||||
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
|
||||||
@@ -177,7 +170,6 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append_unprotected (
|
|||||||
* This routine places the_message at the front of the outstanding
|
* This routine places the_message at the front of the outstanding
|
||||||
* messages on the_message_queue.
|
* messages on the_message_queue.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Prepend_unprotected (
|
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Prepend_unprotected (
|
||||||
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
|
||||||
@@ -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.
|
* This function returns true if the_message_queue is true and false otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_null (
|
RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_null (
|
||||||
CORE_message_queue_Control *the_message_queue
|
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 );
|
return ( the_message_queue == NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
|
||||||
* This function returns true if notification is enabled on this message
|
/**
|
||||||
* queue and false otherwise.
|
* 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
|
* This routine initializes the notification information for
|
||||||
)
|
* @a the_message_queue.
|
||||||
{
|
*/
|
||||||
return (the_message_queue->notify_handler != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify (
|
||||||
* This routine initializes the notification information for the_message_queue.
|
CORE_message_queue_Control *the_message_queue,
|
||||||
*/
|
CORE_message_queue_Notify_Handler the_handler,
|
||||||
|
void *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,
|
the_message_queue->notify_handler = the_handler;
|
||||||
void *the_argument
|
the_message_queue->notify_argument = the_argument;
|
||||||
)
|
}
|
||||||
{
|
#endif
|
||||||
the_message_queue->notify_handler = the_handler;
|
|
||||||
the_message_queue->notify_argument = the_argument;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,9 @@ 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;
|
||||||
_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
|
* Round size up to multiple of a pointer for chain init and
|
||||||
|
|||||||
@@ -56,59 +56,73 @@ void _CORE_message_queue_Insert_message(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
ISR_Level level;
|
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 ) {
|
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
|
||||||
case CORE_MESSAGE_QUEUE_SEND_REQUEST:
|
_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 );
|
_ISR_Disable( level );
|
||||||
if ( the_message_queue->number_of_pending_messages++ == 0 )
|
SET_NOTIFY();
|
||||||
notify = true;
|
the_message_queue->number_of_pending_messages++;
|
||||||
_CORE_message_queue_Append_unprotected(the_message_queue, the_message);
|
_CORE_message_queue_Append_unprotected(the_message_queue, the_message);
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
break;
|
} else if ( submit_type == CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
|
||||||
case CORE_MESSAGE_QUEUE_URGENT_REQUEST:
|
|
||||||
_ISR_Disable( level );
|
_ISR_Disable( level );
|
||||||
if ( the_message_queue->number_of_pending_messages++ == 0 )
|
SET_NOTIFY();
|
||||||
notify = true;
|
the_message_queue->number_of_pending_messages++;
|
||||||
_CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
|
_CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
break;
|
} else {
|
||||||
default:
|
CORE_message_queue_Buffer_control *this_message;
|
||||||
{
|
Chain_Node *the_node;
|
||||||
CORE_message_queue_Buffer_control *this_message;
|
Chain_Control *the_header;
|
||||||
Chain_Node *the_node;
|
|
||||||
Chain_Control *the_header;
|
|
||||||
|
|
||||||
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 ) ) {
|
||||||
|
|
||||||
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 ) {
|
if ( this_message->priority <= the_message->priority ) {
|
||||||
the_node = the_node->next;
|
the_node = the_node->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
_ISR_Disable( level );
|
break;
|
||||||
if ( the_message_queue->number_of_pending_messages++ == 0 )
|
|
||||||
notify = true;
|
|
||||||
_Chain_Insert_unprotected( the_node->previous, &the_message->Node );
|
|
||||||
_ISR_Enable( level );
|
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|
||||||
/*
|
#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
|
* According to POSIX, does this happen before or after the message
|
||||||
* the message is actually in the queue at this point.
|
* 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 )
|
if ( notify && the_message_queue->notify_handler )
|
||||||
(*the_message_queue->notify_handler)( the_message_queue->notify_argument );
|
(*the_message_queue->notify_handler)(the_message_queue->notify_argument);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ void _CORE_message_queue_Seize(
|
|||||||
ISR_Level level;
|
ISR_Level level;
|
||||||
CORE_message_queue_Buffer_control *the_message;
|
CORE_message_queue_Buffer_control *the_message;
|
||||||
Thread_Control *executing;
|
Thread_Control *executing;
|
||||||
Thread_Control *the_thread;
|
|
||||||
|
|
||||||
executing = _Thread_Executing;
|
executing = _Thread_Executing;
|
||||||
executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
|
executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
|
||||||
@@ -79,43 +78,61 @@ void _CORE_message_queue_Seize(
|
|||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
|
|
||||||
*size_p = the_message->Contents.size;
|
*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);
|
_CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size_p);
|
||||||
|
|
||||||
/*
|
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
|
||||||
* There could be a thread waiting to send a message. If there
|
/*
|
||||||
* is not, then we can go ahead and free the buffer.
|
* There is not an API with blocking sends enabled. So return immediately.
|
||||||
*
|
*/
|
||||||
* 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 );
|
_CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
|
||||||
return;
|
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;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !wait ) {
|
if ( !wait ) {
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -69,7 +69,6 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
|
|||||||
Watchdog_Interval timeout
|
Watchdog_Interval timeout
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ISR_Level level;
|
|
||||||
CORE_message_queue_Buffer_control *the_message;
|
CORE_message_queue_Buffer_control *the_message;
|
||||||
Thread_Control *the_thread;
|
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?
|
* Is there a thread currently waiting on this message queue?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( the_message_queue->number_of_pending_messages == 0 ) {
|
if ( the_message_queue->number_of_pending_messages == 0 ) {
|
||||||
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 ) {
|
||||||
@@ -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
|
* No one waiting on the message queue at this time, so attempt to
|
||||||
* queue the message up for a future receive.
|
* queue the message up for a future receive.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( the_message_queue->number_of_pending_messages <
|
if ( the_message_queue->number_of_pending_messages <
|
||||||
the_message_queue->maximum_pending_messages ) {
|
the_message_queue->maximum_pending_messages ) {
|
||||||
|
|
||||||
@@ -126,7 +123,9 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
|
|||||||
size
|
size
|
||||||
);
|
);
|
||||||
the_message->Contents.size = 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(
|
_CORE_message_queue_Insert_message(
|
||||||
the_message_queue,
|
the_message_queue,
|
||||||
@@ -136,46 +135,48 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
|
|||||||
return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
|
return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
|
||||||
* 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;
|
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
|
* Do NOT block on a send if the caller is in an ISR. It is
|
||||||
* deadly to block in an ISR.
|
* 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;
|
||||||
|
|
||||||
/*
|
_ISR_Disable( level );
|
||||||
* WARNING!! executing should NOT be used prior to this point.
|
_Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
|
||||||
* Thus the unusual choice to open a new scope and declare
|
executing->Wait.queue = &the_message_queue->Wait_queue;
|
||||||
* it as a variable. Doing this emphasizes how dangerous it
|
executing->Wait.id = id;
|
||||||
* would be to use this variable prior to here.
|
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 );
|
||||||
Thread_Control *executing = _Thread_Executing;
|
}
|
||||||
|
|
||||||
_ISR_Disable( level );
|
return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT;
|
||||||
_Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
|
#endif
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <rtems/system.h>
|
#include <rtems/system.h>
|
||||||
@@ -31,6 +30,7 @@
|
|||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
#include <rtems/score/isr.h>
|
#include <rtems/score/isr.h>
|
||||||
|
|
||||||
|
#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
|
||||||
/*PAGE
|
/*PAGE
|
||||||
*
|
*
|
||||||
* _Objects_Name_to_id_string
|
* _Objects_Name_to_id_string
|
||||||
|
|||||||
Reference in New Issue
Block a user