implemented timedwait for polling (non-pthread) case
This commit was SVN r2436.
Этот коммит содержится в:
родитель
083555cb2a
Коммит
9e31ea786c
@ -4,6 +4,8 @@
|
||||
#ifndef OMPI_CONDITION_SPINLOCK_H
|
||||
#define OMPI_CONDITION_SPINLOCK_H
|
||||
|
||||
#include "ompi_config.h"
|
||||
#include <sys/time.h>
|
||||
#include "threads/condition.h"
|
||||
#include "threads/mutex.h"
|
||||
#include "runtime/ompi_progress.h"
|
||||
@ -41,6 +43,31 @@ static inline int ompi_condition_timedwait(ompi_condition_t *c,
|
||||
ompi_mutex_t *m,
|
||||
const struct timespec *abstime)
|
||||
{
|
||||
struct timeval tv;
|
||||
uint32_t secs = abstime->tv_sec;
|
||||
uint32_t usecs = abstime->tv_nsec * 1000;
|
||||
gettimeofday(&tv,NULL);
|
||||
|
||||
c->c_waiting++;
|
||||
if (ompi_using_threads()) {
|
||||
while (c->c_signaled == 0 &&
|
||||
(tv.tv_sec <= secs ||
|
||||
(tv.tv_sec == secs && tv.tv_usec < usecs))) {
|
||||
ompi_mutex_unlock(m);
|
||||
ompi_progress();
|
||||
gettimeofday(&tv,NULL);
|
||||
ompi_mutex_lock(m);
|
||||
}
|
||||
} else {
|
||||
while (c->c_signaled == 0 &&
|
||||
(tv.tv_sec <= secs ||
|
||||
(tv.tv_sec == secs && tv.tv_usec < usecs))) {
|
||||
ompi_progress();
|
||||
gettimeofday(&tv,NULL);
|
||||
}
|
||||
}
|
||||
c->c_signaled--;
|
||||
c->c_waiting--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user