[rtems commit] sapi: Use one SMP lock for all chains

Sebastian Huber sebh at rtems.org
Tue Mar 11 09:57:00 UTC 2014


Module:    rtems
Branch:    master
Commit:    ae88aa7927dbbfb7b841dee8133f55c38303b91b
Changeset: http://git.rtems.org/rtems/commit/?id=ae88aa7927dbbfb7b841dee8133f55c38303b91b

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Mar 10 08:15:37 2014 +0100

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.

---

 c/src/lib/libcpu/powerpc/mpc55xx/edma/edma.c |    2 +-
 c/src/libchip/ide/ata.c                      |    2 +-
 cpukit/posix/src/aio_cancel.c                |    4 +-
 cpukit/posix/src/aio_misc.c                  |   21 ++---
 cpukit/sapi/include/rtems/chain.h            |  122 ++++++++-----------------
 cpukit/sapi/src/chainsmp.c                   |   80 ++++++++---------
 testsuites/libtests/block06/init.c           |    4 +-
 testsuites/sptests/spchain/init.c            |    4 +-
 8 files changed, 94 insertions(+), 145 deletions(-)

diff --git a/c/src/lib/libcpu/powerpc/mpc55xx/edma/edma.c b/c/src/lib/libcpu/powerpc/mpc55xx/edma/edma.c
index a2f687b..4354785 100644
--- a/c/src/lib/libcpu/powerpc/mpc55xx/edma/edma.c
+++ b/c/src/lib/libcpu/powerpc/mpc55xx/edma/edma.c
@@ -276,7 +276,7 @@ void mpc55xx_edma_release_channel(edma_channel_context *ctx)
   unsigned channel_index = edma_channel_index_of_tcd(ctx->edma_tcd);
 
   mpc55xx_edma_release_channel_by_tcd(ctx->edma_tcd);
-  rtems_chain_explicit_extract(&edma_channel_chain, &ctx->node);
+  rtems_chain_extract(&ctx->node);
 
   sc = rtems_interrupt_handler_remove(
     MPC55XX_IRQ_EDMA(channel_index),
diff --git a/c/src/libchip/ide/ata.c b/c/src/libchip/ide/ata.c
index 64238b7..8229714 100644
--- a/c/src/libchip/ide/ata.c
+++ b/c/src/libchip/ide/ata.c
@@ -491,7 +491,7 @@ ata_request_done(ata_req_t *areq, rtems_device_minor_number ctrl_minor,
 #endif
 
     ATA_EXEC_CALLBACK(areq, status);
-    rtems_chain_explicit_extract(&ata_ide_ctrls[ctrl_minor].reqs, &areq->link);
+    rtems_chain_extract(&areq->link);
 
     if (!rtems_chain_is_empty(&ata_ide_ctrls[ctrl_minor].reqs))
     {
diff --git a/cpukit/posix/src/aio_cancel.c b/cpukit/posix/src/aio_cancel.c
index aec554e..c3c6be1 100644
--- a/cpukit/posix/src/aio_cancel.c
+++ b/cpukit/posix/src/aio_cancel.c
@@ -55,7 +55,7 @@ int aio_cancel(int fildes, struct aiocb  *aiocbp)
 
         AIO_printf ("Request chain on [IQ]\n");
 
-        rtems_chain_explicit_extract (idle_req_chain, &r_chain->next_fd);
+        rtems_chain_extract (&r_chain->next_fd);
         rtems_aio_remove_fd (r_chain);
         pthread_mutex_destroy (&r_chain->mutex);
         pthread_cond_destroy (&r_chain->mutex);
@@ -72,7 +72,7 @@ int aio_cancel(int fildes, struct aiocb  *aiocbp)
     AIO_printf ("Request chain on [WQ]\n");
 
     pthread_mutex_lock (&r_chain->mutex);
-    rtems_chain_explicit_extract (work_req_chain, &r_chain->next_fd);
+    rtems_chain_extract (&r_chain->next_fd);
     rtems_aio_remove_fd (r_chain);
     pthread_mutex_unlock (&r_chain->mutex);
     pthread_mutex_unlock (&aio_request_queue.mutex);
diff --git a/cpukit/posix/src/aio_misc.c b/cpukit/posix/src/aio_misc.c
index 656ba41..3678573 100644
--- a/cpukit/posix/src/aio_misc.c
+++ b/cpukit/posix/src/aio_misc.c
@@ -120,9 +120,7 @@ rtems_aio_search_fd (rtems_chain_control *chain, int fildes, int create)
       if (rtems_chain_is_empty (chain))
         rtems_chain_prepend (chain, &r_chain->next_fd);
       else
-        rtems_chain_explicit_insert (chain,
-                                     rtems_chain_previous (node),
-                                     &r_chain->next_fd);
+        rtems_chain_insert (rtems_chain_previous (node), &r_chain->next_fd);
 
       r_chain->new_fd = 1;
 	  r_chain->fildes = fildes;
@@ -159,9 +157,7 @@ rtems_aio_move_to_work (rtems_aio_request_chain *r_chain)
     temp = (rtems_aio_request_chain *) node;
   }
 
-  rtems_chain_explicit_insert (work_req_chain,
-                               rtems_chain_previous (node),
-                               &r_chain->next_fd);
+  rtems_chain_insert (rtems_chain_previous (node), &r_chain->next_fd);
 }
  
 
@@ -200,7 +196,7 @@ rtems_aio_insert_prio (rtems_chain_control *chain, rtems_aio_request *req)
       prio = ((rtems_aio_request *) node)->aiocbp->aio_reqprio;
     }
 
-    rtems_chain_explicit_insert (chain, node->previous, &req->next_prio);
+    rtems_chain_insert (node->previous, &req->next_prio);
 
   }
 }
@@ -226,7 +222,7 @@ void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain)
   
   while (!rtems_chain_is_tail (chain, node))
     {
-      rtems_chain_explicit_extract (chain, node);
+      rtems_chain_extract (node);
       rtems_aio_request *req = (rtems_aio_request *) node;
       node = rtems_chain_next (node);
       req->aiocbp->error_code = ECANCELED;
@@ -270,7 +266,7 @@ int rtems_aio_remove_req (rtems_chain_control *chain, struct aiocb *aiocbp)
     return AIO_NOTCANCELED;
   else
     {
-      rtems_chain_explicit_extract (chain, node);
+      rtems_chain_extract (node);
       current->aiocbp->error_code = ECANCELED;
       current->aiocbp->return_value = -1;
       free (current); 
@@ -445,7 +441,7 @@ rtems_aio_handle (void *arg)
       param.sched_priority = req->priority;
       pthread_setschedparam (pthread_self(), req->policy, &param);
 
-      rtems_chain_explicit_extract (chain, node);
+      rtems_chain_extract (node);
 
       pthread_mutex_unlock (&r_chain->mutex);
 
@@ -511,8 +507,7 @@ rtems_aio_handle (void *arg)
 	  /* If no requests were added to the chain we delete the fd chain from 
 	     the queue and start working with idle fd chains */
 	  if (result == ETIMEDOUT) {
-	    rtems_chain_explicit_extract (&aio_request_queue.work_req,
-                                    &r_chain->next_fd);
+	    rtems_chain_extract (&r_chain->next_fd);
 	    pthread_mutex_destroy (&r_chain->mutex);
 	    pthread_cond_destroy (&r_chain->cond);
 	    free (r_chain);
@@ -548,7 +543,7 @@ rtems_aio_handle (void *arg)
 	    ++aio_request_queue.active_threads;
 
 	    node = rtems_chain_first (&aio_request_queue.idle_req);
-	    rtems_chain_explicit_extract (&aio_request_queue.idle_req, node);
+	    rtems_chain_extract (node);
 
 	    r_chain = (rtems_aio_request_chain *) node;
 	    rtems_aio_move_to_work (r_chain);
diff --git a/cpukit/sapi/include/rtems/chain.h b/cpukit/sapi/include/rtems/chain.h
index 0927055..1e64442 100644
--- a/cpukit/sapi/include/rtems/chain.h
+++ b/cpukit/sapi/include/rtems/chain.h
@@ -5,7 +5,7 @@
  */
 
 /*
- *  Copyright (c) 2010 embedded brains GmbH.
+ *  Copyright (c) 2010-2014 embedded brains GmbH.
  *
  *  COPYRIGHT (c) 1989-2008.
  *  On-Line Applications Research Corporation (OAR).
@@ -19,7 +19,6 @@
 #define _RTEMS_CHAIN_H
 
 #include <rtems/score/chainimpl.h>
-#include <rtems/score/isrlock.h>
 #include <rtems/rtems/event.h>
 
 #ifdef __cplusplus
@@ -37,16 +36,13 @@ extern "C" {
 
 typedef Chain_Node rtems_chain_node;
 
-typedef struct {
-  Chain_Control Chain;
-  ISR_lock_Control Lock;
-} rtems_chain_control;
+typedef Chain_Control rtems_chain_control;
 
 /**
  *  @brief Chain initializer for an empty chain with designator @a name.
  */
 #define RTEMS_CHAIN_INITIALIZER_EMPTY( name ) \
-  { CHAIN_INITIALIZER_EMPTY( name.Chain ), ISR_LOCK_INITIALIZER }
+  CHAIN_INITIALIZER_EMPTY( name )
 
 /**
  *  @brief Chain initializer for a chain with one @a node.
@@ -54,7 +50,7 @@ typedef struct {
  *  @see RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN().
  */
 #define RTEMS_CHAIN_INITIALIZER_ONE_NODE( node ) \
-  { CHAIN_INITIALIZER_ONE_NODE( node ), ISR_LOCK_INITIALIZER }
+  CHAIN_INITIALIZER_ONE_NODE( node )
 
 /**
  *  @brief Chain node initializer for a @a chain containing exactly this node.
@@ -62,7 +58,7 @@ typedef struct {
  *  @see RTEMS_CHAIN_INITIALIZER_ONE_NODE().
  */
 #define RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \
-  CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( &( chain )->Chain )
+  CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain )
 
 /**
  *  @brief Chain definition for an empty chain with designator @a name.
@@ -154,9 +150,8 @@ RTEMS_INLINE_ROUTINE void rtems_chain_initialize(
   size_t               node_size
 )
 {
-  _ISR_lock_Initialize( &the_chain->Lock );
   _Chain_Initialize(
-    &the_chain->Chain,
+    the_chain,
     starting_address,
     number_nodes,
     node_size
@@ -174,8 +169,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_initialize_empty(
   rtems_chain_control *the_chain
 )
 {
-  _ISR_lock_Initialize( &the_chain->Lock );
-  _Chain_Initialize_empty( &the_chain->Chain );
+  _Chain_Initialize_empty( the_chain );
 }
 
 /**
@@ -241,7 +235,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_head(
   rtems_chain_control *the_chain
 )
 {
-  return _Chain_Head( &the_chain->Chain );
+  return _Chain_Head( the_chain );
 }
 
 /**
@@ -257,7 +251,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_head(
   const rtems_chain_control *the_chain
 )
 {
-  return _Chain_Immutable_head( &the_chain->Chain );
+  return _Chain_Immutable_head( the_chain );
 }
 
 /**
@@ -273,7 +267,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_tail(
   rtems_chain_control *the_chain
 )
 {
-  return _Chain_Tail( &the_chain->Chain );
+  return _Chain_Tail( the_chain );
 }
 
 /** 
@@ -289,7 +283,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_tail(
   const rtems_chain_control *the_chain
 )
 {
-  return _Chain_Immutable_tail( &the_chain->Chain );
+  return _Chain_Immutable_tail( the_chain );
 }
 
 /**
@@ -306,7 +300,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_first(
   rtems_chain_control *the_chain
 )
 {
-  return _Chain_First( &the_chain->Chain );
+  return _Chain_First( the_chain );
 }
 
 /** 
@@ -323,7 +317,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_first(
   const rtems_chain_control *the_chain
 )
 {
-  return _Chain_Immutable_first( &the_chain->Chain );
+  return _Chain_Immutable_first( the_chain );
 }
 
 /**
@@ -340,7 +334,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_last(
   rtems_chain_control *the_chain
 )
 {
-  return _Chain_Last( &the_chain->Chain );
+  return _Chain_Last( the_chain );
 }
 
 /**
@@ -357,7 +351,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_last(
   const rtems_chain_control *the_chain
 )
 {
-  return _Chain_Immutable_last( &the_chain->Chain );
+  return _Chain_Immutable_last( the_chain );
 }
 
 /**
@@ -459,7 +453,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_empty(
   const rtems_chain_control *the_chain
 )
 {
-  return _Chain_Is_empty( &the_chain->Chain );
+  return _Chain_Is_empty( the_chain );
 }
 
 /**
@@ -514,7 +508,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_has_only_one_node(
   const rtems_chain_control *the_chain
 )
 {
-  return _Chain_Has_only_one_node( &the_chain->Chain );
+  return _Chain_Has_only_one_node( the_chain );
 }
 
 /**
@@ -534,7 +528,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_head(
   const rtems_chain_node *the_node
 )
 {
-  return _Chain_Is_head( &the_chain->Chain, the_node );
+  return _Chain_Is_head( the_chain, the_node );
 }
 
 /**
@@ -554,10 +548,9 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_tail(
   const rtems_chain_node *the_node
 )
 {
-  return _Chain_Is_tail( &the_chain->Chain, the_node );
+  return _Chain_Is_tail( the_chain, the_node );
 }
 
-#if !defined( RTEMS_SMP )
 /**
  * @brief Extract the specified node from a chain.
  *
@@ -567,33 +560,16 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_tail(
  *
  * @arg the_node specifies the node to extract
  */
-RTEMS_INLINE_ROUTINE void rtems_chain_extract(
-  rtems_chain_node *the_node
-)
-{
-  _Chain_Extract( the_node );
-}
-#endif
-
 #if defined( RTEMS_SMP )
-/**
- * @brief Extract the specified node from a chain.
- *
- * @param[in,out] chain The chain containing the node.
- * @param[in,out] node The node to extract.
- */
-void rtems_chain_explicit_extract(
-  rtems_chain_control *chain,
-  rtems_chain_node *node
+void rtems_chain_extract(
+  rtems_chain_node *the_node
 );
 #else
-RTEMS_INLINE_ROUTINE void rtems_chain_explicit_extract(
-  rtems_chain_control *chain,
-  rtems_chain_node *node
+RTEMS_INLINE_ROUTINE void rtems_chain_extract(
+  rtems_chain_node *the_node
 )
 {
-  ( void ) chain;
-  rtems_chain_extract( node );
+  _Chain_Extract( the_node );
 }
 #endif
 
@@ -633,7 +609,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get(
   rtems_chain_control *the_chain
 )
 {
-  return _Chain_Get( &the_chain->Chain );
+  return _Chain_Get( the_chain );
 }
 #endif
 
@@ -644,10 +620,9 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected(
   rtems_chain_control *the_chain
 )
 {
-  return _Chain_Get_unprotected( &the_chain->Chain );
+  return _Chain_Get_unprotected( the_chain );
 }
 
-#if !defined( RTEMS_SMP )
 /**
  * @brief Insert a node on a chain
  *
@@ -657,37 +632,18 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected(
  * NOTE: It disables interrupts to ensure the atomicity
  * of the extract operation.
  */
-RTEMS_INLINE_ROUTINE void rtems_chain_insert(
-  rtems_chain_node *after_node,
-  rtems_chain_node *the_node
-)
-{
-  _Chain_Insert( after_node, the_node );
-}
-#endif
-
-/**
- * @brief Insert a node on a chain
- *
- * @param[in,out] chain The chain containing the after node.
- * @param[in,out] after_node Insert the node after this node.
- * @param[in,out] node The node to insert.
- */
 #if defined( RTEMS_SMP )
-void rtems_chain_explicit_insert(
-  rtems_chain_control *chain,
+void rtems_chain_insert(
   rtems_chain_node *after_node,
-  rtems_chain_node *node
+  rtems_chain_node *the_node
 );
 #else
-RTEMS_INLINE_ROUTINE void rtems_chain_explicit_insert(
-  rtems_chain_control *chain,
+RTEMS_INLINE_ROUTINE void rtems_chain_insert(
   rtems_chain_node *after_node,
-  rtems_chain_node *node
+  rtems_chain_node *the_node
 )
 {
-  ( void ) chain;
-  rtems_chain_insert( after_node, node );
+  _Chain_Insert( after_node, the_node );
 }
 #endif
 
@@ -721,7 +677,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_append(
   rtems_chain_node    *the_node
 )
 {
-  _Chain_Append( &the_chain->Chain, the_node );
+  _Chain_Append( the_chain, the_node );
 }
 #endif
 
@@ -738,7 +694,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_append_unprotected(
   rtems_chain_node    *the_node
 )
 {
-  _Chain_Append_unprotected( &the_chain->Chain, the_node );
+  _Chain_Append_unprotected( the_chain, the_node );
 }
 
 /** 
@@ -763,7 +719,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_prepend(
   rtems_chain_node    *the_node
 )
 {
-  _Chain_Prepend( &the_chain->Chain, the_node );
+  _Chain_Prepend( the_chain, the_node );
 }
 #endif
 
@@ -783,7 +739,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_prepend_unprotected(
   rtems_chain_node    *the_node
 )
 {
-  _Chain_Prepend_unprotected( &the_chain->Chain, the_node );
+  _Chain_Prepend_unprotected( the_chain, the_node );
 }
 
 /**
@@ -805,7 +761,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_append_with_empty_check(
   rtems_chain_node *node
 )
 {
-  return _Chain_Append_with_empty_check( &chain->Chain, node );
+  return _Chain_Append_with_empty_check( chain, node );
 }
 #endif
 
@@ -828,7 +784,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_prepend_with_empty_check(
   rtems_chain_node *node
 )
 {
-  return _Chain_Prepend_with_empty_check( &chain->Chain, node );
+  return _Chain_Prepend_with_empty_check( chain, node );
 }
 #endif
 
@@ -855,7 +811,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_get_with_empty_check(
   rtems_chain_node **node
 )
 {
-  return _Chain_Get_with_empty_check( &chain->Chain, node );
+  return _Chain_Get_with_empty_check( chain, node );
 }
 #endif
 
@@ -873,7 +829,7 @@ RTEMS_INLINE_ROUTINE size_t rtems_chain_node_count_unprotected(
   const rtems_chain_control *chain
 )
 {
-  return _Chain_Node_count_unprotected( &chain->Chain );
+  return _Chain_Node_count_unprotected( chain );
 }
 
 /** @} */
diff --git a/cpukit/sapi/src/chainsmp.c b/cpukit/sapi/src/chainsmp.c
index ea8de83..5554860 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;
 }
diff --git a/testsuites/libtests/block06/init.c b/testsuites/libtests/block06/init.c
index e51bf27..6352aba 100644
--- a/testsuites/libtests/block06/init.c
+++ b/testsuites/libtests/block06/init.c
@@ -1130,14 +1130,14 @@ bdbuf_tests_task_0_test_8 (bdbuf_task_control* tc)
 
   bd = (rtems_bdbuf_buffer*) node;
   pnode = node->previous;
-  rtems_chain_explicit_extract (&buffers, node);
+  rtems_chain_extract (node);
   node = pnode;
   bdbuf_test_printf ("%s: rtems_bdbuf_release_modified[4]: ", tc->name);
   passed = bdbuf_test_print_sc (rtems_bdbuf_release_modified (bd), true);
 
   bd = (rtems_bdbuf_buffer*) node;
   pnode = node->previous;
-  rtems_chain_explicit_extract (&buffers, node);
+  rtems_chain_extract (node);
   node = pnode;
   bdbuf_test_printf ("%s: rtems_bdbuf_release_modified[3]: ", tc->name);
   passed = bdbuf_test_print_sc (rtems_bdbuf_release_modified (bd), true);
diff --git a/testsuites/sptests/spchain/init.c b/testsuites/sptests/spchain/init.c
index 747f404..8ae5390 100644
--- a/testsuites/sptests/spchain/init.c
+++ b/testsuites/sptests/spchain/init.c
@@ -106,7 +106,7 @@ static void test_chain_first_and_last(void)
 
   rtems_chain_initialize_empty( &chain );
   rtems_chain_append( &chain, &node1 );
-  rtems_chain_explicit_insert( &chain, &node1, &node2 );
+  rtems_chain_insert( &node1, &node2 );
 
   puts( "INIT - Verify rtems_chain_is_first" );
   cnode = rtems_chain_first(&chain);  
@@ -308,7 +308,7 @@ rtems_task Init(
   node1.id = 1;
   node2.id = 2;
   rtems_chain_append( &chain1, &node1.Node );
-  rtems_chain_explicit_insert( &chain1, &node1.Node, &node2.Node );
+  rtems_chain_insert( &node1.Node, &node2.Node );
 
   for ( p = rtems_chain_first(&chain1), id = 1 ;
         !rtems_chain_is_tail(&chain1, p) ;




More information about the vc mailing list