[PATCH 04/19] score: _CORE_message_queue_Seize()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Apr 29 09:13:04 UTC 2016
Move lock acquire to caller of _CORE_message_queue_Seize() to allow
state checks during receive operations under lock protection.
---
cpukit/posix/src/mqueuerecvsupp.c | 5 +++++
cpukit/rtems/src/msgqreceive.c | 5 +++++
cpukit/score/src/coremsgseize.c | 1 -
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c
index bbbc234..ecdadb3 100644
--- a/cpukit/posix/src/mqueuerecvsupp.c
+++ b/cpukit/posix/src/mqueuerecvsupp.c
@@ -96,6 +96,11 @@ ssize_t _POSIX_Message_queue_Receive_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/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c
index 3b4945e..e3b3466 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -68,6 +68,11 @@ rtems_status_code rtems_message_queue_receive(
else
wait = true;
+ _CORE_message_queue_Acquire_critical(
+ &the_message_queue->message_queue,
+ &lock_context
+ );
+
executing = _Thread_Executing;
_CORE_message_queue_Seize(
&the_message_queue->message_queue,
diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c
index 5e14918..2471b91 100644
--- a/cpukit/score/src/coremsgseize.c
+++ b/cpukit/score/src/coremsgseize.c
@@ -40,7 +40,6 @@ void _CORE_message_queue_Seize(
CORE_message_queue_Buffer_control *the_message;
executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
- _CORE_message_queue_Acquire_critical( the_message_queue, lock_context );
the_message = _CORE_message_queue_Get_pending_message( the_message_queue );
if ( the_message != NULL ) {
the_message_queue->number_of_pending_messages -= 1;
--
1.8.4.5
More information about the devel
mailing list