summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/percpu.c
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/score/src/percpu.c
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/score/src/percpu.c')
-rw-r--r--cpukit/score/src/percpu.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/cpukit/score/src/percpu.c b/cpukit/score/src/percpu.c
index 3a7a84518e..50e523941c 100644
--- a/cpukit/score/src/percpu.c
+++ b/cpukit/score/src/percpu.c
@@ -28,20 +28,6 @@
static SMP_lock_Control _Per_CPU_State_lock = SMP_LOCK_INITIALIZER;
-static ISR_Level _Per_CPU_State_acquire( void )
-{
- ISR_Level level;
-
- _SMP_lock_ISR_disable_and_acquire( &_Per_CPU_State_lock, level );
-
- return level;
-}
-
-static void _Per_CPU_State_release( ISR_Level level )
-{
- _SMP_lock_Release_and_ISR_enable( &_Per_CPU_State_lock, level );
-}
-
static void _Per_CPU_State_busy_wait(
const Per_CPU_Control *per_cpu,
Per_CPU_State new_state
@@ -126,12 +112,14 @@ void _Per_CPU_State_change(
Per_CPU_State new_state
)
{
- ISR_Level level;
+ SMP_lock_Control *lock = &_Per_CPU_State_lock;
+ SMP_lock_Context lock_context;
Per_CPU_State next_state;
_Per_CPU_State_busy_wait( per_cpu, new_state );
- level = _Per_CPU_State_acquire();
+ _SMP_lock_ISR_disable_and_acquire( lock, &lock_context );
+
next_state = _Per_CPU_State_get_next( per_cpu->state, new_state );
per_cpu->state = next_state;
@@ -159,7 +147,7 @@ void _Per_CPU_State_change(
_CPU_SMP_Processor_event_broadcast();
- _Per_CPU_State_release( level );
+ _SMP_lock_Release_and_ISR_enable( lock, &lock_context );
if (
next_state == PER_CPU_STATE_SHUTDOWN