1
1

Fix ABA problem in atomic_lifo code. This is temporary solution for now. We

are looking for a better one.

This commit was SVN r16091.
Этот коммит содержится в:
Gleb Natapov 2007-09-11 15:40:30 +00:00
родитель e82a6eec27
Коммит 140dce7614
3 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Voltaire All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -71,8 +72,10 @@ static inline opal_list_item_t* opal_atomic_lifo_push( opal_atomic_lifo_t* lifo,
item->opal_list_next = lifo->opal_lifo_head;
if( opal_atomic_cmpset_ptr( &(lifo->opal_lifo_head),
(void*)item->opal_list_next,
item ) )
item ) ) {
opal_atomic_cmpset_32((volatile int32_t*)&item->item_free, 1, 0);
return (opal_list_item_t*)item->opal_list_next;
}
/* DO some kind of pause to release the bus */
} while( 1 );
#else
@ -89,14 +92,17 @@ static inline opal_list_item_t* opal_atomic_lifo_pop( opal_atomic_lifo_t* lifo )
{
opal_list_item_t* item;
#if OMPI_HAVE_THREAD_SUPPORT
do {
item = lifo->opal_lifo_head;
while((item = lifo->opal_lifo_head) != &(lifo->opal_lifo_ghost))
{
if(!opal_atomic_cmpset_32((volatile int32_t*)&item->item_free, 0, 1))
continue;
if( opal_atomic_cmpset_ptr( &(lifo->opal_lifo_head),
item,
(void*)item->opal_list_next ) )
break;
opal_atomic_cmpset_32((volatile int32_t*)&item->item_free, 1, 0);
/* Do some kind of pause to release the bus */
} while( 1 );
}
#else
item = lifo->opal_lifo_head;
lifo->opal_lifo_head = (opal_list_item_t*)item->opal_list_next;

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Voltaire All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -55,6 +56,7 @@ OBJ_CLASS_INSTANCE(
static void opal_list_item_construct(opal_list_item_t *item)
{
item->opal_list_next = item->opal_list_prev = NULL;
item->item_free = 1;
#if OMPI_ENABLE_DEBUG
item->opal_list_item_refcount = 0;
item->opal_list_item_belong_to = NULL;

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Voltaire All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -102,6 +103,7 @@ struct opal_list_item_t
/**< Pointer to next list item */
volatile struct opal_list_item_t *opal_list_prev;
/**< Pointer to previous list item */
int32_t item_free;
#if OMPI_ENABLE_DEBUG
/** Atomic reference count for debugging */