summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-10 08:25:32 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-11 10:58:09 +0100
commitd50acdbb6c8213114ce887a56daea02697c9e1a1 (patch)
treee48fb252786992308fa2dd6337c8a02db35bd10b /cpukit/rtems
parentsapi: Use one SMP lock for all chains (diff)
downloadrtems-d50acdbb6c8213114ce887a56daea02697c9e1a1.tar.bz2
score: Add local context to SMP lock API
Add a local context structure to the SMP lock API for acquire and release pairs. This context can be used to store the ISR level and profiling information. It may be later used to enable more sophisticated lock algorithms, e.g. MCS locks. There is only one lock that cannot be used with a local context. This is the per-CPU lock since here we would have to transfer the local context through a context switch which is very complicated.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/include/rtems/rtems/asrimpl.h18
-rw-r--r--cpukit/rtems/include/rtems/rtems/intr.h31
-rw-r--r--cpukit/rtems/src/clockgetuptimenanoseconds.c6
-rw-r--r--cpukit/rtems/src/clockgetuptimeseconds.c6
4 files changed, 36 insertions, 25 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/asrimpl.h b/cpukit/rtems/include/rtems/rtems/asrimpl.h
index ebb405279b..d67198f175 100644
--- a/cpukit/rtems/include/rtems/rtems/asrimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/asrimpl.h
@@ -61,13 +61,13 @@ RTEMS_INLINE_ROUTINE void _ASR_Swap_signals (
)
{
rtems_signal_set _signals;
- ISR_Level _level;
+ ISR_lock_Context lock_context;
- _ISR_lock_ISR_disable_and_acquire( &asr->Lock, _level );
+ _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context );
_signals = asr->signals_pending;
asr->signals_pending = asr->signals_posted;
asr->signals_posted = _signals;
- _ISR_lock_Release_and_ISR_enable( &asr->Lock, _level );
+ _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context );
}
/**
@@ -110,11 +110,11 @@ RTEMS_INLINE_ROUTINE void _ASR_Post_signals(
rtems_signal_set *signal_set
)
{
- ISR_Level _level;
+ ISR_lock_Context lock_context;
- _ISR_lock_ISR_disable_and_acquire( &asr->Lock, _level );
+ _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context );
*signal_set |= signals;
- _ISR_lock_Release_and_ISR_enable( &asr->Lock, _level );
+ _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context );
}
RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals(
@@ -122,12 +122,12 @@ RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals(
)
{
rtems_signal_set signal_set;
- ISR_Level _level;
+ ISR_lock_Context lock_context;
- _ISR_lock_ISR_disable_and_acquire( &asr->Lock, _level );
+ _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context );
signal_set = asr->signals_posted;
asr->signals_posted = 0;
- _ISR_lock_Release_and_ISR_enable( &asr->Lock, _level );
+ _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context );
return signal_set;
}
diff --git a/cpukit/rtems/include/rtems/rtems/intr.h b/cpukit/rtems/include/rtems/rtems/intr.h
index a98d0bef0e..62d2dad25a 100644
--- a/cpukit/rtems/include/rtems/rtems/intr.h
+++ b/cpukit/rtems/include/rtems/rtems/intr.h
@@ -160,6 +160,11 @@ rtems_status_code rtems_interrupt_catch(
typedef ISR_lock_Control rtems_interrupt_lock;
/**
+ * @brief Local interrupt lock context for acquire and release pairs.
+ */
+typedef ISR_lock_Context rtems_interrupt_lock_context;
+
+/**
* @brief Initializer for static initialization of interrupt locks.
*/
#define RTEMS_INTERRUPT_LOCK_INITIALIZER ISR_LOCK_INITIALIZER
@@ -183,12 +188,13 @@ typedef ISR_lock_Control rtems_interrupt_lock;
* This function can be used in thread and interrupt context.
*
* @param[in,out] _lock The interrupt lock.
- * @param[out] _isr_cookie The interrupt status to restore will be returned.
+ * @param[in,out] _lock_context The local interrupt lock context for an acquire
+ * and release pair.
*
* @see rtems_interrupt_lock_release().
*/
-#define rtems_interrupt_lock_acquire( _lock, _isr_cookie ) \
- _ISR_lock_ISR_disable_and_acquire( _lock, _isr_cookie )
+#define rtems_interrupt_lock_acquire( _lock, _lock_context ) \
+ _ISR_lock_ISR_disable_and_acquire( _lock, _lock_context )
/**
* @brief Releases an interrupt lock.
@@ -199,12 +205,13 @@ typedef ISR_lock_Control rtems_interrupt_lock;
* This function can be used in thread and interrupt context.
*
* @param[in,out] _lock The interrupt lock.
- * @param[in] _isr_cookie The interrupt status to restore.
+ * @param[in,out] _lock_context The local interrupt lock context for an acquire
+ * and release pair.
*
* @see rtems_interrupt_lock_acquire().
*/
-#define rtems_interrupt_lock_release( _lock, _isr_cookie ) \
- _ISR_lock_Release_and_ISR_enable( _lock, _isr_cookie )
+#define rtems_interrupt_lock_release( _lock, _lock_context ) \
+ _ISR_lock_Release_and_ISR_enable( _lock, _lock_context )
/**
* @brief Acquires an interrupt lock in the corresponding interrupt service
@@ -218,11 +225,13 @@ typedef ISR_lock_Control rtems_interrupt_lock;
* protected by this lock, then the result is unpredictable.
*
* @param[in,out] _lock The interrupt lock.
+ * @param[in,out] _lock_context The local interrupt lock context for an acquire
+ * and release pair.
*
* @see rtems_interrupt_lock_release_isr().
*/
-#define rtems_interrupt_lock_acquire_isr( _lock ) \
- _ISR_lock_Acquire( _lock )
+#define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
+ _ISR_lock_Acquire( _lock, _lock_context )
/**
* @brief Releases an interrupt lock in the corresponding interrupt service
@@ -232,11 +241,13 @@ typedef ISR_lock_Control rtems_interrupt_lock;
* function releases an SMP lock.
*
* @param[in,out] _lock The interrupt lock.
+ * @param[in,out] _lock_context The local interrupt lock context for an acquire
+ * and release pair.
*
* @see rtems_interrupt_lock_acquire_isr().
*/
-#define rtems_interrupt_lock_release_isr( _lock ) \
- _ISR_lock_Release( _lock )
+#define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
+ _ISR_lock_Release( _lock, _lock_context )
/** @} */
diff --git a/cpukit/rtems/src/clockgetuptimenanoseconds.c b/cpukit/rtems/src/clockgetuptimenanoseconds.c
index c07a4305db..47775656a8 100644
--- a/cpukit/rtems/src/clockgetuptimenanoseconds.c
+++ b/cpukit/rtems/src/clockgetuptimenanoseconds.c
@@ -24,12 +24,12 @@ uint64_t rtems_clock_get_uptime_nanoseconds( void )
{
Timestamp_Control snapshot_as_timestamp;
uint32_t nanoseconds;
- ISR_Level level;
+ ISR_lock_Context lock_context;
- _TOD_Acquire( &_TOD, level );
+ _TOD_Acquire( &_TOD, &lock_context );
snapshot_as_timestamp = _TOD.uptime;
nanoseconds = ( *_TOD.nanoseconds_since_last_tick )();
- _TOD_Release( &_TOD, level );
+ _TOD_Release( &_TOD, &lock_context );
return _Timestamp_Get_As_nanoseconds( &snapshot_as_timestamp, nanoseconds );
}
diff --git a/cpukit/rtems/src/clockgetuptimeseconds.c b/cpukit/rtems/src/clockgetuptimeseconds.c
index 3b597acaa8..ce4b8a5c9b 100644
--- a/cpukit/rtems/src/clockgetuptimeseconds.c
+++ b/cpukit/rtems/src/clockgetuptimeseconds.c
@@ -31,11 +31,11 @@ time_t rtems_clock_get_uptime_seconds( void )
TOD_Control *tod = &_TOD;
Timestamp_Control snapshot_as_timestamp;
struct timespec snapshot_as_timespec;
- ISR_Level level;
+ ISR_lock_Context lock_context;
- _TOD_Acquire( tod, level );
+ _TOD_Acquire( tod, &lock_context );
snapshot_as_timestamp = tod->uptime;
- _TOD_Release( tod, level );
+ _TOD_Release( tod, &lock_context );
_Timestamp_To_timespec( &snapshot_as_timestamp, &snapshot_as_timespec );