sapi: Use one SMP lock for all chains

This partially reverts commit 1215fd4d94.

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.
This commit is contained in:
Sebastian Huber
2014-03-10 08:15:37 +01:00
parent b1196e3268
commit ae88aa7927
8 changed files with 95 additions and 146 deletions

View File

@@ -276,7 +276,7 @@ void mpc55xx_edma_release_channel(edma_channel_context *ctx)
unsigned channel_index = edma_channel_index_of_tcd(ctx->edma_tcd); unsigned channel_index = edma_channel_index_of_tcd(ctx->edma_tcd);
mpc55xx_edma_release_channel_by_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( sc = rtems_interrupt_handler_remove(
MPC55XX_IRQ_EDMA(channel_index), MPC55XX_IRQ_EDMA(channel_index),

View File

@@ -491,7 +491,7 @@ ata_request_done(ata_req_t *areq, rtems_device_minor_number ctrl_minor,
#endif #endif
ATA_EXEC_CALLBACK(areq, status); 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)) if (!rtems_chain_is_empty(&ata_ide_ctrls[ctrl_minor].reqs))
{ {

View File

@@ -55,7 +55,7 @@ int aio_cancel(int fildes, struct aiocb *aiocbp)
AIO_printf ("Request chain on [IQ]\n"); 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); rtems_aio_remove_fd (r_chain);
pthread_mutex_destroy (&r_chain->mutex); pthread_mutex_destroy (&r_chain->mutex);
pthread_cond_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"); AIO_printf ("Request chain on [WQ]\n");
pthread_mutex_lock (&r_chain->mutex); 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); rtems_aio_remove_fd (r_chain);
pthread_mutex_unlock (&r_chain->mutex); pthread_mutex_unlock (&r_chain->mutex);
pthread_mutex_unlock (&aio_request_queue.mutex); pthread_mutex_unlock (&aio_request_queue.mutex);

View File

@@ -120,9 +120,7 @@ rtems_aio_search_fd (rtems_chain_control *chain, int fildes, int create)
if (rtems_chain_is_empty (chain)) if (rtems_chain_is_empty (chain))
rtems_chain_prepend (chain, &r_chain->next_fd); rtems_chain_prepend (chain, &r_chain->next_fd);
else else
rtems_chain_explicit_insert (chain, rtems_chain_insert (rtems_chain_previous (node), &r_chain->next_fd);
rtems_chain_previous (node),
&r_chain->next_fd);
r_chain->new_fd = 1; r_chain->new_fd = 1;
r_chain->fildes = fildes; 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; temp = (rtems_aio_request_chain *) node;
} }
rtems_chain_explicit_insert (work_req_chain, rtems_chain_insert (rtems_chain_previous (node), &r_chain->next_fd);
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; 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)) 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; rtems_aio_request *req = (rtems_aio_request *) node;
node = rtems_chain_next (node); node = rtems_chain_next (node);
req->aiocbp->error_code = ECANCELED; req->aiocbp->error_code = ECANCELED;
@@ -270,7 +266,7 @@ int rtems_aio_remove_req (rtems_chain_control *chain, struct aiocb *aiocbp)
return AIO_NOTCANCELED; return AIO_NOTCANCELED;
else else
{ {
rtems_chain_explicit_extract (chain, node); rtems_chain_extract (node);
current->aiocbp->error_code = ECANCELED; current->aiocbp->error_code = ECANCELED;
current->aiocbp->return_value = -1; current->aiocbp->return_value = -1;
free (current); free (current);
@@ -445,7 +441,7 @@ rtems_aio_handle (void *arg)
param.sched_priority = req->priority; param.sched_priority = req->priority;
pthread_setschedparam (pthread_self(), req->policy, &param); pthread_setschedparam (pthread_self(), req->policy, &param);
rtems_chain_explicit_extract (chain, node); rtems_chain_extract (node);
pthread_mutex_unlock (&r_chain->mutex); 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 /* If no requests were added to the chain we delete the fd chain from
the queue and start working with idle fd chains */ the queue and start working with idle fd chains */
if (result == ETIMEDOUT) { if (result == ETIMEDOUT) {
rtems_chain_explicit_extract (&aio_request_queue.work_req, rtems_chain_extract (&r_chain->next_fd);
&r_chain->next_fd);
pthread_mutex_destroy (&r_chain->mutex); pthread_mutex_destroy (&r_chain->mutex);
pthread_cond_destroy (&r_chain->cond); pthread_cond_destroy (&r_chain->cond);
free (r_chain); free (r_chain);
@@ -548,7 +543,7 @@ rtems_aio_handle (void *arg)
++aio_request_queue.active_threads; ++aio_request_queue.active_threads;
node = rtems_chain_first (&aio_request_queue.idle_req); 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; r_chain = (rtems_aio_request_chain *) node;
rtems_aio_move_to_work (r_chain); rtems_aio_move_to_work (r_chain);

View File

@@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2010 embedded brains GmbH. * Copyright (c) 2010-2014 embedded brains GmbH.
* *
* COPYRIGHT (c) 1989-2008. * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
@@ -19,7 +19,6 @@
#define _RTEMS_CHAIN_H #define _RTEMS_CHAIN_H
#include <rtems/score/chainimpl.h> #include <rtems/score/chainimpl.h>
#include <rtems/score/isrlock.h>
#include <rtems/rtems/event.h> #include <rtems/rtems/event.h>
#ifdef __cplusplus #ifdef __cplusplus
@@ -37,16 +36,13 @@ extern "C" {
typedef Chain_Node rtems_chain_node; typedef Chain_Node rtems_chain_node;
typedef struct { typedef Chain_Control rtems_chain_control;
Chain_Control Chain;
ISR_lock_Control Lock;
} rtems_chain_control;
/** /**
* @brief Chain initializer for an empty chain with designator @a name. * @brief Chain initializer for an empty chain with designator @a name.
*/ */
#define RTEMS_CHAIN_INITIALIZER_EMPTY( 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. * @brief Chain initializer for a chain with one @a node.
@@ -54,7 +50,7 @@ typedef struct {
* @see RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN(). * @see RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN().
*/ */
#define RTEMS_CHAIN_INITIALIZER_ONE_NODE( node ) \ #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. * @brief Chain node initializer for a @a chain containing exactly this node.
@@ -62,7 +58,7 @@ typedef struct {
* @see RTEMS_CHAIN_INITIALIZER_ONE_NODE(). * @see RTEMS_CHAIN_INITIALIZER_ONE_NODE().
*/ */
#define RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ #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. * @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 size_t node_size
) )
{ {
_ISR_lock_Initialize( &the_chain->Lock );
_Chain_Initialize( _Chain_Initialize(
&the_chain->Chain, the_chain,
starting_address, starting_address,
number_nodes, number_nodes,
node_size node_size
@@ -174,8 +169,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_initialize_empty(
rtems_chain_control *the_chain rtems_chain_control *the_chain
) )
{ {
_ISR_lock_Initialize( &the_chain->Lock ); _Chain_Initialize_empty( the_chain );
_Chain_Initialize_empty( &the_chain->Chain );
} }
/** /**
@@ -241,7 +235,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_head(
rtems_chain_control *the_chain 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 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 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 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 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 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 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 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 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 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 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 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. * @brief Extract the specified node from a chain.
* *
@@ -567,6 +560,11 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_tail(
* *
* @arg the_node specifies the node to extract * @arg the_node specifies the node to extract
*/ */
#if defined( RTEMS_SMP )
void rtems_chain_extract(
rtems_chain_node *the_node
);
#else
RTEMS_INLINE_ROUTINE void rtems_chain_extract( RTEMS_INLINE_ROUTINE void rtems_chain_extract(
rtems_chain_node *the_node rtems_chain_node *the_node
) )
@@ -575,28 +573,6 @@ RTEMS_INLINE_ROUTINE void rtems_chain_extract(
} }
#endif #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
);
#else
RTEMS_INLINE_ROUTINE void rtems_chain_explicit_extract(
rtems_chain_control *chain,
rtems_chain_node *node
)
{
( void ) chain;
rtems_chain_extract( node );
}
#endif
/** /**
* @brief Extract the specified node from a chain (unprotected). * @brief Extract the specified node from a chain (unprotected).
* *
@@ -633,7 +609,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get(
rtems_chain_control *the_chain rtems_chain_control *the_chain
) )
{ {
return _Chain_Get( &the_chain->Chain ); return _Chain_Get( the_chain );
} }
#endif #endif
@@ -644,10 +620,9 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected(
rtems_chain_control *the_chain 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 * @brief Insert a node on a chain
* *
@@ -657,6 +632,12 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected(
* NOTE: It disables interrupts to ensure the atomicity * NOTE: It disables interrupts to ensure the atomicity
* of the extract operation. * of the extract operation.
*/ */
#if defined( RTEMS_SMP )
void rtems_chain_insert(
rtems_chain_node *after_node,
rtems_chain_node *the_node
);
#else
RTEMS_INLINE_ROUTINE void rtems_chain_insert( RTEMS_INLINE_ROUTINE void rtems_chain_insert(
rtems_chain_node *after_node, rtems_chain_node *after_node,
rtems_chain_node *the_node rtems_chain_node *the_node
@@ -666,31 +647,6 @@ RTEMS_INLINE_ROUTINE void rtems_chain_insert(
} }
#endif #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,
rtems_chain_node *after_node,
rtems_chain_node *node
);
#else
RTEMS_INLINE_ROUTINE void rtems_chain_explicit_insert(
rtems_chain_control *chain,
rtems_chain_node *after_node,
rtems_chain_node *node
)
{
( void ) chain;
rtems_chain_insert( after_node, node );
}
#endif
/** /**
* @brief See _Chain_Insert_unprotected(). * @brief See _Chain_Insert_unprotected().
*/ */
@@ -721,7 +677,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_append(
rtems_chain_node *the_node rtems_chain_node *the_node
) )
{ {
_Chain_Append( &the_chain->Chain, the_node ); _Chain_Append( the_chain, the_node );
} }
#endif #endif
@@ -738,7 +694,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_append_unprotected(
rtems_chain_node *the_node 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 rtems_chain_node *the_node
) )
{ {
_Chain_Prepend( &the_chain->Chain, the_node ); _Chain_Prepend( the_chain, the_node );
} }
#endif #endif
@@ -783,7 +739,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_prepend_unprotected(
rtems_chain_node *the_node 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 rtems_chain_node *node
) )
{ {
return _Chain_Append_with_empty_check( &chain->Chain, node ); return _Chain_Append_with_empty_check( chain, node );
} }
#endif #endif
@@ -828,7 +784,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_prepend_with_empty_check(
rtems_chain_node *node rtems_chain_node *node
) )
{ {
return _Chain_Prepend_with_empty_check( &chain->Chain, node ); return _Chain_Prepend_with_empty_check( chain, node );
} }
#endif #endif
@@ -855,7 +811,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_get_with_empty_check(
rtems_chain_node **node rtems_chain_node **node
) )
{ {
return _Chain_Get_with_empty_check( &chain->Chain, node ); return _Chain_Get_with_empty_check( chain, node );
} }
#endif #endif
@@ -873,7 +829,7 @@ RTEMS_INLINE_ROUTINE size_t rtems_chain_node_count_unprotected(
const rtems_chain_control *chain const rtems_chain_control *chain
) )
{ {
return _Chain_Node_count_unprotected( &chain->Chain ); return _Chain_Node_count_unprotected( chain );
} }
/** @} */ /** @} */

View File

@@ -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 * embedded brains GmbH
* Dornierstr. 4 * Dornierstr. 4
@@ -20,16 +20,27 @@
#if defined( RTEMS_SMP ) #if defined( RTEMS_SMP )
void rtems_chain_explicit_extract( #include <rtems/score/smplock.h>
rtems_chain_control *chain,
rtems_chain_node *node 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_Level level;
_ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); chain_acquire( &level );
_Chain_Extract_unprotected( node ); _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 ) 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; rtems_chain_node *node;
ISR_Level level; ISR_Level level;
_ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); chain_acquire( &level );
node = _Chain_Get_unprotected( &chain->Chain ); node = _Chain_Get_unprotected( chain );
_ISR_lock_Release_and_ISR_enable( &chain->Lock, level ); chain_release( &level );
return node; return node;
} }
void rtems_chain_explicit_insert( void rtems_chain_insert( rtems_chain_node *after_node, rtems_chain_node *node )
rtems_chain_control *chain,
rtems_chain_node *after_node,
rtems_chain_node *node
)
{ {
ISR_Level level; ISR_Level level;
_ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); chain_acquire( &level );
_Chain_Insert_unprotected( after_node, node ); _Chain_Insert_unprotected( after_node, node );
_ISR_lock_Release_and_ISR_enable( &chain->Lock, level ); chain_release( &level );
} }
void rtems_chain_append( void rtems_chain_append(
@@ -64,9 +71,9 @@ void rtems_chain_append(
{ {
ISR_Level level; ISR_Level level;
_ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); chain_acquire( &level );
_Chain_Append_unprotected( &chain->Chain, node ); _Chain_Append_unprotected( chain, node );
_ISR_lock_Release_and_ISR_enable( &chain->Lock, level ); chain_release( &level );
} }
void rtems_chain_prepend( void rtems_chain_prepend(
@@ -76,9 +83,9 @@ void rtems_chain_prepend(
{ {
ISR_Level level; ISR_Level level;
_ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); chain_acquire( &level );
_Chain_Prepend_unprotected( &chain->Chain, node ); _Chain_Prepend_unprotected( chain, node );
_ISR_lock_Release_and_ISR_enable( &chain->Lock, level ); chain_release( &level );
} }
bool rtems_chain_append_with_empty_check( bool rtems_chain_append_with_empty_check(
@@ -89,12 +96,9 @@ bool rtems_chain_append_with_empty_check(
bool was_empty; bool was_empty;
ISR_Level level; ISR_Level level;
_ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); chain_acquire( &level );
was_empty = _Chain_Append_with_empty_check_unprotected( was_empty = _Chain_Append_with_empty_check_unprotected( chain, node );
&chain->Chain, chain_release( &level );
node
);
_ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
return was_empty; return was_empty;
} }
@@ -107,12 +111,9 @@ bool rtems_chain_prepend_with_empty_check(
bool was_empty; bool was_empty;
ISR_Level level; ISR_Level level;
_ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); chain_acquire( &level );
was_empty = _Chain_Prepend_with_empty_check_unprotected( was_empty = _Chain_Prepend_with_empty_check_unprotected( chain, node );
&chain->Chain, chain_release( &level );
node
);
_ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
return was_empty; return was_empty;
} }
@@ -125,12 +126,9 @@ bool rtems_chain_get_with_empty_check(
bool is_empty_now; bool is_empty_now;
ISR_Level level; ISR_Level level;
_ISR_lock_ISR_disable_and_acquire( &chain->Lock, level ); chain_acquire( &level );
is_empty_now = _Chain_Get_with_empty_check_unprotected( is_empty_now = _Chain_Get_with_empty_check_unprotected( chain, node );
&chain->Chain, chain_release( &level );
node
);
_ISR_lock_Release_and_ISR_enable( &chain->Lock, level );
return is_empty_now; return is_empty_now;
} }

View File

@@ -1130,14 +1130,14 @@ bdbuf_tests_task_0_test_8 (bdbuf_task_control* tc)
bd = (rtems_bdbuf_buffer*) node; bd = (rtems_bdbuf_buffer*) node;
pnode = node->previous; pnode = node->previous;
rtems_chain_explicit_extract (&buffers, node); rtems_chain_extract (node);
node = pnode; node = pnode;
bdbuf_test_printf ("%s: rtems_bdbuf_release_modified[4]: ", tc->name); bdbuf_test_printf ("%s: rtems_bdbuf_release_modified[4]: ", tc->name);
passed = bdbuf_test_print_sc (rtems_bdbuf_release_modified (bd), true); passed = bdbuf_test_print_sc (rtems_bdbuf_release_modified (bd), true);
bd = (rtems_bdbuf_buffer*) node; bd = (rtems_bdbuf_buffer*) node;
pnode = node->previous; pnode = node->previous;
rtems_chain_explicit_extract (&buffers, node); rtems_chain_extract (node);
node = pnode; node = pnode;
bdbuf_test_printf ("%s: rtems_bdbuf_release_modified[3]: ", tc->name); bdbuf_test_printf ("%s: rtems_bdbuf_release_modified[3]: ", tc->name);
passed = bdbuf_test_print_sc (rtems_bdbuf_release_modified (bd), true); passed = bdbuf_test_print_sc (rtems_bdbuf_release_modified (bd), true);

View File

@@ -106,7 +106,7 @@ static void test_chain_first_and_last(void)
rtems_chain_initialize_empty( &chain ); rtems_chain_initialize_empty( &chain );
rtems_chain_append( &chain, &node1 ); rtems_chain_append( &chain, &node1 );
rtems_chain_explicit_insert( &chain, &node1, &node2 ); rtems_chain_insert( &node1, &node2 );
puts( "INIT - Verify rtems_chain_is_first" ); puts( "INIT - Verify rtems_chain_is_first" );
cnode = rtems_chain_first(&chain); cnode = rtems_chain_first(&chain);
@@ -308,7 +308,7 @@ rtems_task Init(
node1.id = 1; node1.id = 1;
node2.id = 2; node2.id = 2;
rtems_chain_append( &chain1, &node1.Node ); 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 ; for ( p = rtems_chain_first(&chain1), id = 1 ;
!rtems_chain_is_tail(&chain1, p) ; !rtems_chain_is_tail(&chain1, p) ;