summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coremsginsert.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2005-09-01 16:32:06 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2005-09-01 16:32:06 +0000
commit2bbe78a24927567bfe6bfbde292ce500486fcfc8 (patch)
tree9043e4854cc3f41bffd33df63b61b67721e59e76 /cpukit/score/src/coremsginsert.c
parent2005-09-01 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-2bbe78a24927567bfe6bfbde292ce500486fcfc8.tar.bz2
2005-09-01 Joel Sherrill <joel@OARcorp.com>
PR 820/rtems * score/inline/rtems/score/coremsg.inl, score/macros/rtems/score/coremsg.inl, score/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.
Diffstat (limited to 'cpukit/score/src/coremsginsert.c')
-rw-r--r--cpukit/score/src/coremsginsert.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/cpukit/score/src/coremsginsert.c b/cpukit/score/src/coremsginsert.c
index 4644010366..2402755447 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
@@ -58,19 +58,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;
@@ -89,7 +97,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;
}
@@ -100,7 +112,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 );
}