From cc18d7bec7b3c5515cb9e6cd9771d4b94309b3bd Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 30 Apr 2015 13:12:54 +0200 Subject: score: Fine grained locking for message queues Aggregate several critical sections into a bigger one. Sending and receiving messages is now protected by an ISR lock. Thread dispatching is only disabled in case a blocking operation is necessary. The message copy procedure is done inside the critical section (interrupts disabled). Thus this change may have a negative impact on the interrupt latency in case very large messages are transferred. Update #2273. --- cpukit/posix/src/mqueuerecvsupp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'cpukit/posix/src/mqueuerecvsupp.c') diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c index bea19fe9ca..2f9bb2d276 100644 --- a/cpukit/posix/src/mqueuerecvsupp.c +++ b/cpukit/posix/src/mqueuerecvsupp.c @@ -54,20 +54,25 @@ ssize_t _POSIX_Message_queue_Receive_support( size_t length_out; bool do_wait; Thread_Control *executing; + ISR_lock_Context lock_context; - the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location ); + the_mq_fd = _POSIX_Message_queue_Get_fd_interrupt_disable( + mqdes, + &location, + &lock_context + ); switch ( location ) { case OBJECTS_LOCAL: if ( (the_mq_fd->oflag & O_ACCMODE) == O_WRONLY ) { - _Objects_Put( &the_mq_fd->Object ); + _ISR_lock_ISR_enable( &lock_context ); rtems_set_errno_and_return_minus_one( EBADF ); } the_mq = the_mq_fd->Queue; if ( msg_len < the_mq->Message_queue.maximum_message_size ) { - _Objects_Put( &the_mq_fd->Object ); + _ISR_lock_ISR_enable( &lock_context ); rtems_set_errno_and_return_minus_one( EMSGSIZE ); } @@ -97,10 +102,10 @@ ssize_t _POSIX_Message_queue_Receive_support( msg_ptr, &length_out, do_wait, - timeout + timeout, + &lock_context ); - _Objects_Put( &the_mq_fd->Object ); if (msg_prio) { *msg_prio = _POSIX_Message_queue_Priority_from_core( executing->Wait.count -- cgit v1.2.3