summaryrefslogtreecommitdiffstats
path: root/cpukit/sapi/src/chainsmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/sapi/src/chainsmp.c')
-rw-r--r--cpukit/sapi/src/chainsmp.c80
1 files changed, 39 insertions, 41 deletions
diff --git a/cpukit/sapi/src/chainsmp.c b/cpukit/sapi/src/chainsmp.c
index ea8de83a0b..5554860280 100644
--- a/cpukit/sapi/src/chainsmp.c
+++ b/cpukit/sapi/src/chainsmp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -20,16 +20,27 @@
#if defined( RTEMS_SMP )
-void rtems_chain_explicit_extract(
- rtems_chain_control *chain,
- rtems_chain_node *node
-)
+#include <rtems/score/smplock.h>
+
+static SMP_lock_Control chain_lock = SMP_LOCK_INITIALIZER;
+
+static void chain_acquire( ISR_Level *level )
+{
+ _SMP_lock_ISR_disable_and_acquire( &chain_lock, *level );
+}
+
+static void chain_release( ISR_Level *level )
+{
+ _SMP_lock_Release_and_ISR_enable( &chain_lock, *level );
+}
+
+void rtems_chain_extract( rtems_chain_node *node )
{
ISR_Level level;
- _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level );
+ chain_acquire( &level );
_Chain_Extract_unprotected( node );
- _ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
+ chain_release( &level );
}
rtems_chain_node *rtems_chain_get( rtems_chain_control *chain )
@@ -37,24 +48,20 @@ rtems_chain_node *rtems_chain_get( rtems_chain_control *chain )
rtems_chain_node *node;
ISR_Level level;
- _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level );
- node = _Chain_Get_unprotected( &chain->Chain );
- _ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
+ chain_acquire( &level );
+ node = _Chain_Get_unprotected( chain );
+ chain_release( &level );
return node;
}
-void rtems_chain_explicit_insert(
- rtems_chain_control *chain,
- rtems_chain_node *after_node,
- rtems_chain_node *node
-)
+void rtems_chain_insert( rtems_chain_node *after_node, rtems_chain_node *node )
{
ISR_Level level;
- _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level );
+ chain_acquire( &level );
_Chain_Insert_unprotected( after_node, node );
- _ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
+ chain_release( &level );
}
void rtems_chain_append(
@@ -64,9 +71,9 @@ void rtems_chain_append(
{
ISR_Level level;
- _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level );
- _Chain_Append_unprotected( &chain->Chain, node );
- _ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
+ chain_acquire( &level );
+ _Chain_Append_unprotected( chain, node );
+ chain_release( &level );
}
void rtems_chain_prepend(
@@ -76,9 +83,9 @@ void rtems_chain_prepend(
{
ISR_Level level;
- _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level );
- _Chain_Prepend_unprotected( &chain->Chain, node );
- _ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
+ chain_acquire( &level );
+ _Chain_Prepend_unprotected( chain, node );
+ chain_release( &level );
}
bool rtems_chain_append_with_empty_check(
@@ -89,12 +96,9 @@ bool rtems_chain_append_with_empty_check(
bool was_empty;
ISR_Level level;
- _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level );
- was_empty = _Chain_Append_with_empty_check_unprotected(
- &chain->Chain,
- node
- );
- _ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
+ chain_acquire( &level );
+ was_empty = _Chain_Append_with_empty_check_unprotected( chain, node );
+ chain_release( &level );
return was_empty;
}
@@ -107,12 +111,9 @@ bool rtems_chain_prepend_with_empty_check(
bool was_empty;
ISR_Level level;
- _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level );
- was_empty = _Chain_Prepend_with_empty_check_unprotected(
- &chain->Chain,
- node
- );
- _ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
+ chain_acquire( &level );
+ was_empty = _Chain_Prepend_with_empty_check_unprotected( chain, node );
+ chain_release( &level );
return was_empty;
}
@@ -125,12 +126,9 @@ bool rtems_chain_get_with_empty_check(
bool is_empty_now;
ISR_Level level;
- _ISR_lock_ISR_disable_and_acquire( &chain->Lock, level );
- is_empty_now = _Chain_Get_with_empty_check_unprotected(
- &chain->Chain,
- node
- );
- _ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
+ chain_acquire( &level );
+ is_empty_now = _Chain_Get_with_empty_check_unprotected( chain, node );
+ chain_release( &level );
return is_empty_now;
}