[rtems commit] rtems: Avoid Giant lock in rtems_signal_catch()
Sebastian Huber
sebh at rtems.org
Thu Mar 17 08:03:45 UTC 2016
Module: rtems
Branch: master
Commit: 92dee4ab9cf806553d0cdaeb4968d25ced4a8b3a
Changeset: http://git.rtems.org/rtems/commit/?id=92dee4ab9cf806553d0cdaeb4968d25ced4a8b3a
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Mar 17 06:51:56 2016 +0100
rtems: Avoid Giant lock in rtems_signal_catch()
Update #2555.
---
cpukit/rtems/include/rtems/rtems/asrimpl.h | 28 ++++++++++++++++++++++------
cpukit/rtems/src/signalcatch.c | 11 ++++++-----
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/cpukit/rtems/include/rtems/rtems/asrimpl.h b/cpukit/rtems/include/rtems/rtems/asrimpl.h
index bcfb69a..7c1c648 100644
--- a/cpukit/rtems/include/rtems/rtems/asrimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/asrimpl.h
@@ -59,6 +59,22 @@ RTEMS_INLINE_ROUTINE void _ASR_Destroy( ASR_Information *asr )
_ISR_lock_Destroy( &asr->Lock );
}
+RTEMS_INLINE_ROUTINE void _ASR_Acquire(
+ ASR_Information *asr,
+ ISR_lock_Context *lock_context
+)
+{
+ _ISR_lock_ISR_disable_and_acquire( &asr->Lock, lock_context );
+}
+
+RTEMS_INLINE_ROUTINE void _ASR_Release(
+ ASR_Information *asr,
+ ISR_lock_Context *lock_context
+)
+{
+ _ISR_lock_Release_and_ISR_enable( &asr->Lock, lock_context );
+}
+
/**
* @brief ASR_Swap_signals
*
@@ -73,11 +89,11 @@ RTEMS_INLINE_ROUTINE void _ASR_Swap_signals (
rtems_signal_set _signals;
ISR_lock_Context lock_context;
- _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context );
+ _ASR_Acquire( asr, &lock_context );
_signals = asr->signals_pending;
asr->signals_pending = asr->signals_posted;
asr->signals_posted = _signals;
- _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context );
+ _ASR_Release( asr, &lock_context );
}
/**
@@ -122,9 +138,9 @@ RTEMS_INLINE_ROUTINE void _ASR_Post_signals(
{
ISR_lock_Context lock_context;
- _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context );
+ _ASR_Acquire( asr, &lock_context );
*signal_set |= signals;
- _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context );
+ _ASR_Release( asr, &lock_context );
}
RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals(
@@ -134,10 +150,10 @@ RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals(
rtems_signal_set signal_set;
ISR_lock_Context lock_context;
- _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context );
+ _ASR_Acquire( asr, &lock_context );
signal_set = asr->signals_posted;
asr->signals_posted = 0;
- _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context );
+ _ASR_Release( asr, &lock_context );
return signal_set;
}
diff --git a/cpukit/rtems/src/signalcatch.c b/cpukit/rtems/src/signalcatch.c
index f0c62f7..7bf298d 100644
--- a/cpukit/rtems/src/signalcatch.c
+++ b/cpukit/rtems/src/signalcatch.c
@@ -72,21 +72,22 @@ rtems_status_code rtems_signal_catch(
Thread_Control *executing;
RTEMS_API_Control *api;
ASR_Information *asr;
+ ISR_lock_Context lock_context;
executing = _Thread_Get_executing();
api = (RTEMS_API_Control*)executing->API_Extensions[ THREAD_API_RTEMS ];
asr = &api->Signal;
- _Thread_Disable_dispatch(); /* cannot reschedule while */
- /* the thread is inconsistent */
+ _ASR_Acquire( asr, &lock_context );
if ( !_ASR_Is_null_handler( asr_handler ) ) {
asr->mode_set = mode_set;
asr->handler = asr_handler;
- }
- else
+ } else {
_ASR_Initialize( asr );
- _Thread_Enable_dispatch();
+ }
+
+ _ASR_Release( asr, &lock_context );
return RTEMS_SUCCESSFUL;
}
More information about the vc
mailing list