From 7e66865e17d7a82add541056de13717793da002a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 29 Apr 2016 11:05:36 +0200 Subject: score: Move message notification Move message notification to end of critical section and delegate the message queue release to the notification handler. It may do more complex notification actions out of the critical section. Update #2555. --- cpukit/score/src/coremsgsubmit.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cpukit/score/src/coremsgsubmit.c') diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c index 1d6d298ea7..7e589e7754 100644 --- a/cpukit/score/src/coremsgsubmit.c +++ b/cpukit/score/src/coremsgsubmit.c @@ -79,7 +79,28 @@ CORE_message_queue_Status _CORE_message_queue_Do_submit( size, submit_type ); + +#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 ( + the_message_queue->number_of_pending_messages == 1 + && the_message_queue->notify_handler != NULL + ) { + ( *the_message_queue->notify_handler )( + the_message_queue, + lock_context + ); + } else { + _CORE_message_queue_Release( the_message_queue, lock_context ); + } +#else _CORE_message_queue_Release( the_message_queue, lock_context ); +#endif + return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; } -- cgit v1.2.3