If debug is enabled, provide an mca param and supporting logic to output when OPAL_ACQUIRE_THREAD is waiting and has obtained the thread, and when OPAL_RELEASE_THREAD releases it.
This commit was SVN r23557.
Этот коммит содержится в:
родитель
b8db8d0ef8
Коммит
9c69175117
@ -32,6 +32,7 @@
|
||||
#include "opal/datatype/opal_datatype.h"
|
||||
#include "opal/mca/base/mca_base_param.h"
|
||||
#include "opal/threads/mutex.h"
|
||||
#include "opal/threads/threads.h"
|
||||
#include "opal/mca/paffinity/base/base.h"
|
||||
|
||||
int opal_register_params(void)
|
||||
@ -104,6 +105,12 @@ int opal_register_params(void)
|
||||
"warning messages when double-locks are detected.",
|
||||
false, false, 0, &value);
|
||||
if (value) opal_mutex_check_locks = true;
|
||||
|
||||
mca_base_param_reg_int_name("opal", "debug_threads",
|
||||
"Debug thread usage within OPAL. Reports out "
|
||||
"when threads are acquired and released.",
|
||||
false, false, 0, &value);
|
||||
if (value) opal_debug_threads = true;
|
||||
}
|
||||
#endif
|
||||
/* The ddt engine has a few parameters */
|
||||
|
@ -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) 2010 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -21,6 +22,7 @@
|
||||
#include "opal/threads/threads.h"
|
||||
#include "opal/constants.h"
|
||||
|
||||
bool opal_debug_threads = false;
|
||||
|
||||
static void opal_thread_construct(opal_thread_t *t);
|
||||
|
||||
|
@ -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) 2010 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -28,6 +29,10 @@
|
||||
#endif
|
||||
|
||||
#include "opal/class/opal_object.h"
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
#include "opal/util/output.h"
|
||||
#endif
|
||||
|
||||
#include "mutex.h"
|
||||
#include "condition.h"
|
||||
|
||||
@ -58,23 +63,62 @@ struct opal_thread_t {
|
||||
|
||||
typedef struct opal_thread_t opal_thread_t;
|
||||
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
OPAL_DECLSPEC extern bool opal_debug_threads;
|
||||
#endif
|
||||
|
||||
|
||||
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_thread_t);
|
||||
|
||||
#define OPAL_ACQUIRE_THREAD(lck, cnd, act) \
|
||||
do { \
|
||||
OPAL_THREAD_LOCK((lck)); \
|
||||
while (*(act)) { \
|
||||
opal_condition_wait((cnd), (lck)); \
|
||||
} \
|
||||
*(act) = true; \
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
#define OPAL_ACQUIRE_THREAD(lck, cnd, act) \
|
||||
do { \
|
||||
OPAL_THREAD_LOCK((lck)); \
|
||||
if (opal_debug_threads) { \
|
||||
opal_output(0, "Waiting for thread %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
while (*(act)) { \
|
||||
opal_condition_wait((cnd), (lck)); \
|
||||
} \
|
||||
if (opal_debug_threads) { \
|
||||
opal_output(0, "Thread obtained %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
*(act) = true; \
|
||||
} while(0);
|
||||
#else
|
||||
#define OPAL_ACQUIRE_THREAD(lck, cnd, act) \
|
||||
do { \
|
||||
OPAL_THREAD_LOCK((lck)); \
|
||||
while (*(act)) { \
|
||||
opal_condition_wait((cnd), (lck)); \
|
||||
} \
|
||||
*(act) = true; \
|
||||
} while(0);
|
||||
#endif
|
||||
|
||||
#define OPAL_RELEASE_THREAD(lck, cnd, act) \
|
||||
do { \
|
||||
*(act) = false; \
|
||||
opal_condition_broadcast((cnd)); \
|
||||
OPAL_THREAD_UNLOCK((lck)); \
|
||||
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
#define OPAL_RELEASE_THREAD(lck, cnd, act) \
|
||||
do { \
|
||||
if (opal_debug_threads) { \
|
||||
opal_output(0, "Releasing thread %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
*(act) = false; \
|
||||
opal_condition_broadcast((cnd)); \
|
||||
OPAL_THREAD_UNLOCK((lck)); \
|
||||
} while(0);
|
||||
#else
|
||||
#define OPAL_RELEASE_THREAD(lck, cnd, act) \
|
||||
do { \
|
||||
*(act) = false; \
|
||||
opal_condition_broadcast((cnd)); \
|
||||
OPAL_THREAD_UNLOCK((lck)); \
|
||||
} while(0);
|
||||
#endif
|
||||
|
||||
|
||||
#define OPAL_WAKEUP_THREAD(cnd, act) \
|
||||
do { \
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user