summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2005-09-01 16:31:22 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2005-09-01 16:31:22 +0000
commit0bb4dd03373e081afe88b82eea816950de7536f3 (patch)
treee5bac58d27e5fb5370dda13b0f646731358e18ce
parent2005-09-01 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-0bb4dd03373e081afe88b82eea816950de7536f3.tar.bz2
2005-09-01 Joel Sherrill <joel@OARcorp.com>
PR 820/rtems * inline/rtems/score/coremsg.inl, macros/rtems/score/coremsg.inl, src/coremsginsert.c: Increment of pending message count should be atomic with insertion on the pending message chain. Determination of the need to call the notification handler should also be in this atomic section of code.
-rw-r--r--cpukit/score/ChangeLog9
-rw-r--r--cpukit/score/inline/rtems/score/coremsg.inl15
-rw-r--r--cpukit/score/macros/rtems/score/coremsg.inl10
-rw-r--r--cpukit/score/src/coremsginsert.c27
4 files changed, 43 insertions, 18 deletions
diff --git a/cpukit/score/ChangeLog b/cpukit/score/ChangeLog
index 19ada3cc3e..aea807b6d0 100644
--- a/cpukit/score/ChangeLog
+++ b/cpukit/score/ChangeLog
@@ -1,3 +1,12 @@
+2005-09-01 Joel Sherrill <joel@OARcorp.com>
+
+ PR 820/rtems
+ * inline/rtems/score/coremsg.inl, macros/rtems/score/coremsg.inl,
+ src/coremsginsert.c: Increment of pending message count should be
+ atomic with insertion on the pending message chain. Determination of
+ the need to call the notification handler should also be in this
+ atomic section of code.
+
2005-08-17 Andrew Sinclair <Andrew.Sinclair@elprotech.com>
PR 807/rtems
diff --git a/cpukit/score/inline/rtems/score/coremsg.inl b/cpukit/score/inline/rtems/score/coremsg.inl
index 292ad2565d..c320600287 100644
--- a/cpukit/score/inline/rtems/score/coremsg.inl
+++ b/cpukit/score/inline/rtems/score/coremsg.inl
@@ -182,7 +182,7 @@ RTEMS_INLINE_ROUTINE boolean _CORE_message_queue_Is_priority(
/*PAGE
*
- * _CORE_message_queue_Append
+ * _CORE_message_queue_Append_unprotected
*
* DESCRIPTION:
*
@@ -190,17 +190,20 @@ RTEMS_INLINE_ROUTINE boolean _CORE_message_queue_Is_priority(
* messages on the_message_queue.
*/
-RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append (
+RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append_unprotected (
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Buffer_control *the_message
)
{
- _Chain_Append( &the_message_queue->Pending_messages, &the_message->Node );
+ _Chain_Append_unprotected(
+ &the_message_queue->Pending_messages,
+ &the_message->Node
+ );
}
/*PAGE
*
- * _CORE_message_queue_Prepend
+ * _CORE_message_queue_Prepend_unprotected
*
* DESCRIPTION:
*
@@ -208,12 +211,12 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append (
* messages on the_message_queue.
*/
-RTEMS_INLINE_ROUTINE void _CORE_message_queue_Prepend (
+RTEMS_INLINE_ROUTINE void _CORE_message_queue_Prepend_unprotected (
CORE_message_queue_Control *the_message_queue,
CORE_message_queue_Buffer_control *the_message
)
{
- _Chain_Prepend(
+ _Chain_Prepend_unprotected(
&the_message_queue->Pending_messages,
&the_message->Node
);
diff --git a/cpukit/score/macros/rtems/score/coremsg.inl b/cpukit/score/macros/rtems/score/coremsg.inl
index 488d06904b..fd7f3096fa 100644
--- a/cpukit/score/macros/rtems/score/coremsg.inl
+++ b/cpukit/score/macros/rtems/score/coremsg.inl
@@ -97,8 +97,9 @@
*
*/
-#define _CORE_message_queue_Append( _the_message_queue, _the_message ) \
- _Chain_Append( &(_the_message_queue)->Pending_messages, \
+#define _CORE_message_queue_Append_unprotected( \
+ _the_message_queue, _the_message ) \
+ _Chain_Append_unprotected( &(_the_message_queue)->Pending_messages, \
&(_the_message)->Node )
/*PAGE
@@ -107,8 +108,9 @@
*
*/
-#define _CORE_message_queue_Prepend( _the_message_queue, _the_message ) \
- _Chain_Prepend( &(_the_message_queue)->Pending_messages, \
+#define _CORE_message_queue_Prepend_unprotected( \
+ _the_message_queue, _the_message ) \
+ _Chain_Prepend_unprotected( &(_the_message_queue)->Pending_messages, \
&(_the_message)->Node )
/*PAGE
diff --git a/cpukit/score/src/coremsginsert.c b/cpukit/score/src/coremsginsert.c
index 21f8f8dd25..6d9c60c158 100644
--- a/cpukit/score/src/coremsginsert.c
+++ b/cpukit/score/src/coremsginsert.c
@@ -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-2005.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -54,19 +54,27 @@ void _CORE_message_queue_Insert_message(
CORE_message_queue_Submit_types submit_type
)
{
- the_message_queue->number_of_pending_messages += 1;
+ ISR_Level level;
+ boolean notify = FALSE;
the_message->priority = submit_type;
switch ( submit_type ) {
case CORE_MESSAGE_QUEUE_SEND_REQUEST:
- _CORE_message_queue_Append( the_message_queue, the_message );
+ _ISR_Disable( level );
+ if ( the_message_queue->number_of_pending_messages++ == 0 )
+ notify = TRUE;
+ _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
+ _ISR_Enable( level );
break;
case CORE_MESSAGE_QUEUE_URGENT_REQUEST:
- _CORE_message_queue_Prepend( the_message_queue, the_message );
+ _ISR_Disable( level );
+ if ( the_message_queue->number_of_pending_messages++ == 0 )
+ notify = TRUE;
+ _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
+ _ISR_Enable( level );
break;
default:
- /* XXX interrupt critical section needs to be addressed */
{
CORE_message_queue_Buffer_control *this_message;
Chain_Node *the_node;
@@ -85,7 +93,11 @@ void _CORE_message_queue_Insert_message(
break;
}
- _Chain_Insert( the_node->previous, &the_message->Node );
+ _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;
}
@@ -96,7 +108,6 @@ void _CORE_message_queue_Insert_message(
* the message is actually in the queue at this point.
*/
- if ( the_message_queue->number_of_pending_messages == 1 &&
- the_message_queue->notify_handler )
+ if ( notify && the_message_queue->notify_handler )
(*the_message_queue->notify_handler)( the_message_queue->notify_argument );
}