Skip to content

Commit 40e0c41

Browse files
committed
Merge pull request open-mpi#550 from hjelmn/v2.x_recursive_lock
v2.x recursive lock
2 parents 4ab272a + 8a6fc59 commit 40e0c41

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

opal/mca/rcache/vma/rcache_vma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void mca_rcache_vma_module_init( mca_rcache_vma_module_t* rcache ) {
4242
rcache->base.rcache_clean = mca_rcache_vma_clean;
4343
rcache->base.rcache_finalize = mca_rcache_vma_finalize;
4444
rcache->base.rcache_dump_range = mca_rcache_vma_dump_range;
45-
OBJ_CONSTRUCT(&rcache->base.lock, opal_mutex_t);
45+
OBJ_CONSTRUCT(&rcache->base.lock, opal_recursive_mutex_t);
4646
mca_rcache_vma_tree_init(rcache);
4747
}
4848

opal/threads/mutex.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,29 @@ OBJ_CLASS_INSTANCE(opal_mutex_t,
7272
opal_object_t,
7373
opal_mutex_construct,
7474
opal_mutex_destruct);
75+
76+
static void opal_recursive_mutex_construct(opal_recursive_mutex_t *m)
77+
{
78+
pthread_mutexattr_t attr;
79+
pthread_mutexattr_init(&attr);
80+
81+
#if OPAL_ENABLE_DEBUG
82+
m->m_lock_debug = 0;
83+
m->m_lock_file = NULL;
84+
m->m_lock_line = 0;
85+
#endif
86+
87+
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
88+
89+
pthread_mutex_init(&m->m_lock_pthread, &attr);
90+
pthread_mutexattr_destroy(&attr);
91+
92+
#if OPAL_HAVE_ATOMIC_SPINLOCKS
93+
opal_atomic_init( &m->m_lock_atomic, OPAL_ATOMIC_UNLOCKED );
94+
#endif
95+
}
96+
97+
OBJ_CLASS_INSTANCE(opal_recursive_mutex_t,
98+
opal_object_t,
99+
opal_recursive_mutex_construct,
100+
opal_mutex_destruct);

opal/threads/mutex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ OPAL_DECLSPEC extern bool opal_uses_threads;
5050
* Opaque mutex object
5151
*/
5252
typedef struct opal_mutex_t opal_mutex_t;
53-
53+
typedef struct opal_mutex_t opal_recursive_mutex_t;
5454

5555
/**
5656
* Try to acquire a mutex.

opal/threads/mutex_unix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct opal_mutex_t {
6161
opal_atomic_lock_t m_lock_atomic;
6262
};
6363
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_mutex_t);
64+
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_recursive_mutex_t);
6465

6566
/************************************************************************
6667
*

0 commit comments

Comments
 (0)