[PATCH 05/19] score: _CORE_message_queue_Submit()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 29 09:13:05 UTC 2016


Move lock acquire to caller of _CORE_message_queue_Submit() to allow
state checks during send operations under lock protection.
---
 cpukit/posix/src/mqueuesendsupp.c | 5 +++++
 cpukit/rtems/src/msgqsend.c       | 4 ++++
 cpukit/rtems/src/msgqurgent.c     | 4 ++++
 cpukit/score/src/coremsgsubmit.c  | 4 +---
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c
index e158706..ade92b0 100644
--- a/cpukit/posix/src/mqueuesendsupp.c
+++ b/cpukit/posix/src/mqueuesendsupp.c
@@ -96,6 +96,11 @@ int _POSIX_Message_queue_Send_support(
       else
         do_wait = wait;
 
+      _CORE_message_queue_Acquire_critical(
+        &the_mq->Message_queue,
+        &lock_context
+      );
+
       /*
        *  Now perform the actual message receive
        */
diff --git a/cpukit/rtems/src/msgqsend.c b/cpukit/rtems/src/msgqsend.c
index 6f3009d..355475c 100644
--- a/cpukit/rtems/src/msgqsend.c
+++ b/cpukit/rtems/src/msgqsend.c
@@ -52,6 +52,10 @@ rtems_status_code rtems_message_queue_send(
   switch ( location ) {
 
     case OBJECTS_LOCAL:
+      _CORE_message_queue_Acquire_critical(
+        &the_message_queue->message_queue,
+        &lock_context
+      );
       status = _CORE_message_queue_Send(
         &the_message_queue->message_queue,
         buffer,
diff --git a/cpukit/rtems/src/msgqurgent.c b/cpukit/rtems/src/msgqurgent.c
index a328741..430f9a1 100644
--- a/cpukit/rtems/src/msgqurgent.c
+++ b/cpukit/rtems/src/msgqurgent.c
@@ -52,6 +52,10 @@ rtems_status_code rtems_message_queue_urgent(
   switch ( location ) {
 
     case OBJECTS_LOCAL:
+      _CORE_message_queue_Acquire_critical(
+        &the_message_queue->message_queue,
+        &lock_context
+      );
       status = _CORE_message_queue_Urgent(
         &the_message_queue->message_queue,
         buffer,
diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
index f63fa39..61d1330 100644
--- a/cpukit/score/src/coremsgsubmit.c
+++ b/cpukit/score/src/coremsgsubmit.c
@@ -44,12 +44,10 @@ CORE_message_queue_Status _CORE_message_queue_Do_submit(
   Thread_Control                    *the_thread;
 
   if ( size > the_message_queue->maximum_message_size ) {
-    _ISR_lock_ISR_enable( lock_context );
+    _CORE_message_queue_Release( the_message_queue, lock_context );
     return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
   }
 
-  _CORE_message_queue_Acquire_critical( the_message_queue, lock_context );
-
   /*
    *  Is there a thread currently waiting on this message queue?
    */
-- 
1.8.4.5




More information about the devel mailing list