Restore thread-supported condition waits when thread support requested
This commit was SVN r24377.
Этот коммит содержится в:
родитель
94356e98d4
Коммит
e8c2519280
@ -75,6 +75,11 @@ static inline int opal_condition_wait(opal_condition_t *c, opal_mutex_t *m)
|
||||
#endif
|
||||
|
||||
if (opal_using_threads()) {
|
||||
#if OPAL_HAVE_POSIX_THREADS && OPAL_HAVE_THREAD_SUPPORT
|
||||
rc = pthread_cond_wait(&c->c_cond, &m->m_lock_pthread);
|
||||
#elif OPAL_HAVE_SOLARIS_THREADS && OPAL_HAVE_THREAD_SUPPORT
|
||||
rc = cond_wait(&c->c_cond, &m->m_lock_solaris);
|
||||
#else
|
||||
if (c->c_signaled) {
|
||||
c->c_waiting--;
|
||||
opal_mutex_unlock(m);
|
||||
@ -89,6 +94,7 @@ static inline int opal_condition_wait(opal_condition_t *c, opal_mutex_t *m)
|
||||
OPAL_CR_TEST_CHECKPOINT_READY_STALL();
|
||||
opal_mutex_lock(m);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
while (c->c_signaled == 0) {
|
||||
opal_progress();
|
||||
@ -122,6 +128,15 @@ static inline int opal_condition_timedwait(opal_condition_t *c,
|
||||
|
||||
c->c_waiting++;
|
||||
if (opal_using_threads()) {
|
||||
#if OPAL_HAVE_POSIX_THREADS && OPAL_HAVE_THREAD_SUPPORT
|
||||
rc = pthread_cond_timedwait(&c->c_cond, &m->m_lock_pthread, abstime);
|
||||
#elif OPAL_HAVE_SOLARIS_THREADS && OPAL_HAVE_THREAD_SUPPORT
|
||||
/* deal with const-ness */
|
||||
timestruc_t to;
|
||||
to.tv_sec = abstime->tv_sec;
|
||||
to.tv_nsec = abstime->tv_nsec;
|
||||
rc = cond_timedwait(&c->c_cond, &m->m_lock_solaris, &to);
|
||||
#else
|
||||
absolute.tv_sec = abstime->tv_sec;
|
||||
absolute.tv_usec = abstime->tv_nsec * 1000;
|
||||
gettimeofday(&tv,NULL);
|
||||
@ -135,6 +150,7 @@ static inline int opal_condition_timedwait(opal_condition_t *c,
|
||||
(tv.tv_sec <= absolute.tv_sec ||
|
||||
(tv.tv_sec == absolute.tv_sec && tv.tv_usec < absolute.tv_usec)));
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
absolute.tv_sec = abstime->tv_sec;
|
||||
absolute.tv_usec = abstime->tv_nsec * 1000;
|
||||
@ -162,6 +178,15 @@ static inline int opal_condition_signal(opal_condition_t *c)
|
||||
{
|
||||
if (c->c_waiting) {
|
||||
c->c_signaled++;
|
||||
#if OPAL_HAVE_POSIX_THREADS && OPAL_HAVE_THREAD_SUPPORT
|
||||
if(opal_using_threads()) {
|
||||
pthread_cond_signal(&c->c_cond);
|
||||
}
|
||||
#elif OPAL_HAVE_SOLARIS_THREADS && OPAL_HAVE_THREAD_SUPPORT
|
||||
if(opal_using_threads()) {
|
||||
cond_signal(&c->c_cond);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -169,6 +194,19 @@ static inline int opal_condition_signal(opal_condition_t *c)
|
||||
static inline int opal_condition_broadcast(opal_condition_t *c)
|
||||
{
|
||||
c->c_signaled = c->c_waiting;
|
||||
#if OPAL_HAVE_POSIX_THREADS && OPAL_HAVE_THREAD_SUPPORT
|
||||
if (opal_using_threads()) {
|
||||
if( 1 == c->c_waiting ) {
|
||||
pthread_cond_signal(&c->c_cond);
|
||||
} else {
|
||||
pthread_cond_broadcast(&c->c_cond);
|
||||
}
|
||||
}
|
||||
#elif OPAL_HAVE_SOLARIS_THREADS && OPAL_HAVE_THREAD_SUPPORT
|
||||
if (opal_using_threads()) {
|
||||
cond_broadcast(&c->c_cond);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user