Skip to content
Snippets Groups Projects
Commit d6b95ea6 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

nailed it. once we've got the sleep mutex, make sure there's nothing in 'our'...

nailed it. once we've got the sleep mutex, make sure there's nothing in 'our' queue before taking a nap.
parent a64f50b2
No related branches found
No related tags found
2 merge requests!136Master,!122Rewait fixes
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
/* MPI headers. */ /* MPI headers. */
#ifdef WITH_MPI #ifdef WITH_MPI
...@@ -1279,7 +1278,7 @@ struct task *scheduler_gettask(struct scheduler *s, int qid, ...@@ -1279,7 +1278,7 @@ struct task *scheduler_gettask(struct scheduler *s, int qid,
if (res != NULL) break; if (res != NULL) break;
} }
} }
/* If we failed, take a short nap. */ /* If we failed, take a short nap. */
#ifdef WITH_MPI #ifdef WITH_MPI
if (res == NULL && qid > 1) { if (res == NULL && qid > 1) {
...@@ -1287,7 +1286,10 @@ struct task *scheduler_gettask(struct scheduler *s, int qid, ...@@ -1287,7 +1286,10 @@ struct task *scheduler_gettask(struct scheduler *s, int qid,
if (res == NULL) { if (res == NULL) {
#endif #endif
pthread_mutex_lock(&s->sleep_mutex); pthread_mutex_lock(&s->sleep_mutex);
if (s->waiting > 0) pthread_cond_wait(&s->sleep_cond, &s->sleep_mutex); res = queue_gettask(&s->queues[qid], prev, 0);
if (res == NULL && s->waiting > 0) {
pthread_cond_wait(&s->sleep_cond, &s->sleep_mutex);
}
pthread_mutex_unlock(&s->sleep_mutex); pthread_mutex_unlock(&s->sleep_mutex);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment