From 1215fd4d9426a59d568560e9a485628560363133 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 26 Aug 2013 15:14:33 +0200 Subject: sapi: SMP support for chains Add ISR lock to chain control for proper SMP protection. Replace rtems_chain_extract() with rtems_chain_explicit_extract() and rtems_chain_insert() with rtems_chain_explicit_insert() on SMP configurations. Use rtems_chain_explicit_extract() and rtems_chain_explicit_insert() to provide SMP support. --- testsuites/sptests/spchain/init.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'testsuites/sptests/spchain') diff --git a/testsuites/sptests/spchain/init.c b/testsuites/sptests/spchain/init.c index 219d0f3b52..747f4045c4 100644 --- a/testsuites/sptests/spchain/init.c +++ b/testsuites/sptests/spchain/init.c @@ -60,17 +60,29 @@ static void test_chain_control_initializer(void) static void test_chain_control_layout(void) { - rtems_chain_control chain; + Chain_Control chain; + puts( "INIT - Verify rtems_chain_control layout" ); + + rtems_test_assert( + sizeof(Chain_Control) + == sizeof(Chain_Node) + sizeof(Chain_Node *) + ); rtems_test_assert( - sizeof(rtems_chain_control) - == sizeof(rtems_chain_node) + sizeof(rtems_chain_node *) + sizeof(Chain_Control) + == 3 * sizeof(Chain_Node *) ); rtems_test_assert( - sizeof(rtems_chain_control) - == 3 * sizeof(rtems_chain_node *) + _Chain_Previous( _Chain_Head( &chain ) ) + == _Chain_Next( _Chain_Tail( &chain ) ) ); - rtems_test_assert( &chain.Head.Node.previous == &chain.Tail.Node.next ); + +#if !defined( RTEMS_SMP ) + rtems_test_assert( + sizeof(Chain_Control) + == sizeof(rtems_chain_control) + ); +#endif } static void test_chain_get_with_wait(void) @@ -94,7 +106,7 @@ static void test_chain_first_and_last(void) rtems_chain_initialize_empty( &chain ); rtems_chain_append( &chain, &node1 ); - rtems_chain_insert( &node1, &node2 ); + rtems_chain_explicit_insert( &chain, &node1, &node2 ); puts( "INIT - Verify rtems_chain_is_first" ); cnode = rtems_chain_first(&chain); @@ -296,7 +308,7 @@ rtems_task Init( node1.id = 1; node2.id = 2; rtems_chain_append( &chain1, &node1.Node ); - rtems_chain_insert( &node1.Node, &node2.Node ); + rtems_chain_explicit_insert( &chain1, &node1.Node, &node2.Node ); for ( p = rtems_chain_first(&chain1), id = 1 ; !rtems_chain_is_tail(&chain1, p) ; -- cgit v1.2.3