From bb2ad039a7246eecde65592a5116c86d3dede34b Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 4 May 2016 10:09:45 +0200 Subject: rtems: Avoid Giant lock for signals Update #2555. --- cpukit/rtems/include/rtems/rtems/asrimpl.h | 66 ++++++++++-------------------- 1 file changed, 21 insertions(+), 45 deletions(-) (limited to 'cpukit/rtems/include/rtems/rtems/asrimpl.h') diff --git a/cpukit/rtems/include/rtems/rtems/asrimpl.h b/cpukit/rtems/include/rtems/rtems/asrimpl.h index 7c1c648533..892c58c595 100644 --- a/cpukit/rtems/include/rtems/rtems/asrimpl.h +++ b/cpukit/rtems/include/rtems/rtems/asrimpl.h @@ -59,41 +59,29 @@ RTEMS_INLINE_ROUTINE void _ASR_Destroy( ASR_Information *asr ) _ISR_lock_Destroy( &asr->Lock ); } -RTEMS_INLINE_ROUTINE void _ASR_Acquire( +RTEMS_INLINE_ROUTINE void _ASR_Acquire_critical( ASR_Information *asr, ISR_lock_Context *lock_context ) { - _ISR_lock_ISR_disable_and_acquire( &asr->Lock, lock_context ); + _ISR_lock_Acquire( &asr->Lock, lock_context ); } -RTEMS_INLINE_ROUTINE void _ASR_Release( +RTEMS_INLINE_ROUTINE void _ASR_Acquire( ASR_Information *asr, ISR_lock_Context *lock_context ) { - _ISR_lock_Release_and_ISR_enable( &asr->Lock, lock_context ); + _ISR_lock_ISR_disable( lock_context ); + _ASR_Acquire_critical( asr, lock_context ); } -/** - * @brief ASR_Swap_signals - * - * This routine atomically swaps the pending and posted signal - * sets. This is done when the thread alters its mode in such a - * way that the RTEMS_ASR disable/enable flag changes. - */ -RTEMS_INLINE_ROUTINE void _ASR_Swap_signals ( - ASR_Information *asr +RTEMS_INLINE_ROUTINE void _ASR_Release( + ASR_Information *asr, + ISR_lock_Context *lock_context ) { - rtems_signal_set _signals; - ISR_lock_Context lock_context; - - _ASR_Acquire( asr, &lock_context ); - _signals = asr->signals_pending; - asr->signals_pending = asr->signals_posted; - asr->signals_posted = _signals; - _ASR_Release( asr, &lock_context ); + _ISR_lock_Release_and_ISR_enable( &asr->Lock, lock_context ); } /** @@ -109,38 +97,26 @@ RTEMS_INLINE_ROUTINE bool _ASR_Is_null_handler ( return asr_handler == NULL; } -/** - * @brief ASR_Are_signals_pending - * - * This function returns TRUE if there are signals pending in the - * given RTEMS_ASR information record and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _ASR_Are_signals_pending ( - ASR_Information *asr -) +RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Swap_signals( ASR_Information *asr ) { - return asr->signals_posted != 0; + rtems_signal_set new_signals_posted; + ISR_lock_Context lock_context; + + _ASR_Acquire( asr, &lock_context ); + new_signals_posted = asr->signals_pending; + asr->signals_pending = asr->signals_posted; + asr->signals_posted = new_signals_posted; + _ASR_Release( asr, &lock_context ); + + return new_signals_posted; } -/** - * @brief ASR_Post_signals - * - * This routine posts the given signals into the signal_set - * passed in. The result is returned to the user in signal_set. - * - * NOTE: This must be implemented as a macro. - */ RTEMS_INLINE_ROUTINE void _ASR_Post_signals( - ASR_Information *asr, rtems_signal_set signals, rtems_signal_set *signal_set ) { - ISR_lock_Context lock_context; - - _ASR_Acquire( asr, &lock_context ); - *signal_set |= signals; - _ASR_Release( asr, &lock_context ); + *signal_set |= signals; } RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals( -- cgit v1.2.3