Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions opal/mca/pmix/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ OPAL_DECLSPEC int opal_pmix_base_exchange(opal_value_t *info,

OPAL_DECLSPEC void opal_pmix_base_set_evbase(opal_event_base_t *evbase);

#define opal_pmix_condition_wait(a,b) pthread_cond_wait(a, &(b)->m_lock_pthread)
typedef pthread_cond_t opal_pmix_condition_t;
#define opal_pmix_condition_broadcast(a) pthread_cond_broadcast(a)
#define opal_pmix_condition_signal(a) pthread_cond_signal(a)
#define OPAL_PMIX_CONDITION_STATIC_INIT PTHREAD_COND_INITIALIZER
#define opal_pmix_condition_wait(a,b) opal_cond_wait(a, b)
typedef opal_cond_t opal_pmix_condition_t;
#define opal_pmix_condition_broadcast(a) opal_cond_broadcast(a)
#define opal_pmix_condition_signal(a) opal_cond_signal(a)
#define OPAL_PMIX_CONDITION_STATIC_INIT OPAL_CONDITION_STATIC_INIT

typedef struct {
opal_mutex_t mutex;
Expand All @@ -81,7 +81,7 @@ extern opal_pmix_base_t opal_pmix_base;
#define OPAL_PMIX_CONSTRUCT_LOCK(l) \
do { \
OBJ_CONSTRUCT(&(l)->mutex, opal_mutex_t); \
pthread_cond_init(&(l)->cond, NULL); \
opal_cond_init(&(l)->cond); \
(l)->active = true; \
OPAL_POST_OBJECT((l)); \
} while(0)
Expand All @@ -90,7 +90,7 @@ extern opal_pmix_base_t opal_pmix_base;
do { \
OPAL_ACQUIRE_OBJECT((l)); \
OBJ_DESTRUCT(&(l)->mutex); \
pthread_cond_destroy(&(l)->cond); \
opal_cond_destroy(&(l)->cond); \
} while(0)


Expand Down
53 changes: 43 additions & 10 deletions opal/mca/threads/pthreads/threads_pthreads_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@
#include "opal/mca/threads/mutex.h"
//#include "opal/mca/threads/pthreads/mutex_unix.h"


OBJ_CLASS_INSTANCE(opal_mutex_t,
opal_object_t,
NULL,
NULL);
OBJ_CLASS_INSTANCE(opal_recursive_mutex_t,
opal_object_t,
NULL,
NULL);

/*
* Wait and see if some upper layer wants to use threads, if support
* exists.
Expand All @@ -63,3 +53,46 @@ struct opal_pthread_mutex_t {
typedef struct opal_pthread_mutex_t opal_pthread_mutex_t;
typedef struct opal_pthread_mutex_t opal_pthread_recursive_mutex_t;

static void mca_threads_pthreads_mutex_constructor(opal_mutex_t *p_mutex) {
pthread_mutex_init(&p_mutex->m_lock_pthread, NULL);
#if OPAL_ENABLE_DEBUG
p_mutex->m_lock_debug = 0;
p_mutex->m_lock_file = NULL;
p_mutex->m_lock_line = 0;
#endif
opal_atomic_lock_init(&p_mutex->m_lock_atomic, 0);
}

static void mca_threads_pthreads_mutex_desctructor(opal_mutex_t *p_mutex) {
pthread_mutex_destroy(&p_mutex->m_lock_pthread);
}

static void mca_threads_pthreads_recursive_mutex_constructor
(opal_recursive_mutex_t *p_mutex) {
pthread_mutexattr_t mutex_attr;
pthread_mutexattr_init(&mutex_attr);
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&p_mutex->m_lock_pthread, &mutex_attr);
pthread_mutexattr_destroy(&mutex_attr);
#if OPAL_ENABLE_DEBUG
p_mutex->m_lock_debug = 0;
p_mutex->m_lock_file = NULL;
p_mutex->m_lock_line = 0;
#endif
opal_atomic_lock_init(&p_mutex->m_lock_atomic, 0);
}

static void mca_threads_pthreads_recursive_mutex_desctructor
(opal_recursive_mutex_t *p_mutex) {
pthread_mutex_destroy(&p_mutex->m_lock_pthread);
}

OBJ_CLASS_INSTANCE(opal_mutex_t,
opal_object_t,
mca_threads_pthreads_mutex_constructor,
mca_threads_pthreads_mutex_desctructor);

OBJ_CLASS_INSTANCE(opal_recursive_mutex_t,
opal_object_t,
mca_threads_pthreads_recursive_mutex_constructor,
mca_threads_pthreads_recursive_mutex_desctructor);
8 changes: 8 additions & 0 deletions opal/mca/threads/pthreads/threads_pthreads_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ static inline void opal_mutex_atomic_unlock(opal_mutex_t *m)

#endif

typedef pthread_cond_t opal_cond_t;
#define OPAL_CONDITION_STATIC_INIT PTHREAD_COND_INITIALIZER
#define opal_cond_init(a) pthread_cond_init(a, NULL)
#define opal_cond_wait(a,b) pthread_cond_wait(a, &(b)->m_lock_pthread)
#define opal_cond_broadcast(a) pthread_cond_broadcast(a)
#define opal_cond_signal(a) pthread_cond_signal(a)
#define opal_cond_destroy(a) pthread_cond_destroy(a)

END_C_DECLS

#endif /* OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_MUTEX_H */
1 change: 1 addition & 0 deletions opal/mca/timer/linux/timer_linux_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "opal_config.h"

#include <string.h>
#include <time.h>

#include "opal/mca/timer/timer.h"
#include "opal/mca/timer/base/base.h"
Expand Down
14 changes: 7 additions & 7 deletions orte/util/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
* we only have a memory barrier */
#define ORTE_ACQUIRE_OBJECT(o) opal_atomic_rmb()

#define orte_condition_wait(a,b) pthread_cond_wait(a, &(b)->m_lock_pthread)
typedef pthread_cond_t orte_condition_t;
#define orte_condition_broadcast(a) pthread_cond_broadcast(a)
#define orte_condition_signal(a) pthread_cond_signal(a)
#define ORTE_CONDITION_STATIC_INIT PTHREAD_COND_INITIALIZER
#define orte_condition_wait(a,b) opal_cond_wait(a,b)
typedef opal_cond_t orte_condition_t;
#define orte_condition_broadcast(a) opal_cond_broadcast(a)
#define orte_condition_signal(a) opal_cond_signal(a)
#define ORTE_CONDITION_STATIC_INIT OPAL_COND_INITIALIZER

/* define a threadshift macro */
#define ORTE_THREADSHIFT(x, eb, f, p) \
Expand All @@ -51,14 +51,14 @@ typedef struct {
#define ORTE_CONSTRUCT_LOCK(l) \
do { \
OBJ_CONSTRUCT(&(l)->mutex, opal_mutex_t); \
pthread_cond_init(&(l)->cond, NULL); \
opal_cond_init(&(l)->cond); \
(l)->active = true; \
} while(0)

#define ORTE_DESTRUCT_LOCK(l) \
do { \
OBJ_DESTRUCT(&(l)->mutex); \
pthread_cond_destroy(&(l)->cond); \
opal_cond_destroy(&(l)->cond); \
} while(0)


Expand Down