summaryrefslogtreecommitdiffstats
path: root/cpukit/sapi/src/chainsmp.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-10 08:15:37 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-11 10:58:09 +0100
commitae88aa7927dbbfb7b841dee8133f55c38303b91b (patch)
tree2b2b447a0c4a7848fb493044453226f0ec883545 /cpukit/sapi/src/chainsmp.c
parentprintk: Add support for long long (diff)
downloadrtems-ae88aa7927dbbfb7b841dee8133f55c38303b91b.tar.bz2
sapi: Use one SMP lock for all chains
This partially reverts commit 1215fd4d9426a59d568560e9a485628560363133. In order to support profiling of SMP locks and provide a future compatible SMP locks API it is necessary to add an SMP lock destroy function. Since the commit above adds an SMP lock to each chain control we would have to add a rtems_chain_destroy() function as well. This complicates the chain usage dramatically. Thus revert the patch above. A global SMP lock for all chains is used to implement the protected chain operations. Advantages: * The SAPI chain API is now identical on SMP and non-SMP configurations. * The size of the chain control is reduced and is then equal to the Score chains. * The protected chain operations work correctly on SMP. Disadvantage: * Applications using many different chains and the protected operations may notice lock contention. The chain control size drop is a huge benefit (SAPI chain controls are 66% larger than the Score chain controls). The only disadvantage is not really a problem since these applications can use specific interrupt locks and unprotected chain operations to avoid this issue.
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;
}