diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-04-30 13:12:54 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-19 12:00:46 +0200 |
commit | cc18d7bec7b3c5515cb9e6cd9771d4b94309b3bd (patch) | |
tree | 59fd8c8ca70830762e632e255a2078f22ac6a821 /cpukit/posix | |
parent | score: Delete _CORE_message_queue_Flush_support() (diff) | |
download | rtems-cc18d7bec7b3c5515cb9e6cd9771d4b94309b3bd.tar.bz2 |
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.
Diffstat (limited to 'cpukit/posix')
-rw-r--r-- | cpukit/posix/include/rtems/posix/mqueueimpl.h | 15 | ||||
-rw-r--r-- | cpukit/posix/src/mqueuerecvsupp.c | 15 | ||||
-rw-r--r-- | cpukit/posix/src/mqueuesendsupp.c | 14 |
3 files changed, 34 insertions, 10 deletions
diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h index bfc850d990..90269bf57b 100644 --- a/cpukit/posix/include/rtems/posix/mqueueimpl.h +++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h @@ -250,6 +250,21 @@ RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *_POSIX_Message_queue_Get_fd location ); } + +RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd * +_POSIX_Message_queue_Get_fd_interrupt_disable( + mqd_t id, + Objects_Locations *location, + ISR_lock_Context *lock_context +) +{ + return (POSIX_Message_queue_Control_fd *) _Objects_Get_isr_disable( + &_POSIX_Message_queue_Information_fds, + (Objects_Id)id, + location, + lock_context + ); +} /** * @see _POSIX_Name_to_id(). 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 diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c index 2d6ddae859..d73538ae88 100644 --- a/cpukit/posix/src/mqueuesendsupp.c +++ b/cpukit/posix/src/mqueuesendsupp.c @@ -64,6 +64,7 @@ int _POSIX_Message_queue_Send_support( CORE_message_queue_Status msg_status; bool do_wait; Thread_Control *executing; + ISR_lock_Context lock_context; /* * Validate the priority. @@ -73,12 +74,16 @@ int _POSIX_Message_queue_Send_support( if ( msg_prio > MQ_PRIO_MAX ) rtems_set_errno_and_return_minus_one( EINVAL ); - 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_RDONLY ) { - _Objects_Put( &the_mq_fd->Object ); + _ISR_lock_ISR_enable( &lock_context ); rtems_set_errno_and_return_minus_one( EBADF ); } @@ -105,11 +110,10 @@ int _POSIX_Message_queue_Send_support( NULL, _POSIX_Message_queue_Priority_to_core( msg_prio ), do_wait, - timeout /* no timeout */ + timeout, /* no timeout */ + &lock_context ); - _Objects_Put( &the_mq_fd->Object ); - /* * If we had to block, then this is where the task returns * after it wakes up. The returned status is correct for |