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

fix bug in scheduler_done by removing dead code that was causing it.

parent b88b284a
No related branches found
No related tags found
1 merge request!50Parallel sorting
...@@ -128,7 +128,7 @@ void scheduler_splittasks(struct scheduler *s) { ...@@ -128,7 +128,7 @@ void scheduler_splittasks(struct scheduler *s) {
else else
break; break;
} }
/* Skip sorting tasks. */ /* Skip sorting tasks. */
if (t->type == task_type_psort) continue; if (t->type == task_type_psort) continue;
...@@ -1029,45 +1029,34 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { ...@@ -1029,45 +1029,34 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
struct task *scheduler_done(struct scheduler *s, struct task *t) { struct task *scheduler_done(struct scheduler *s, struct task *t) {
int k, res;
struct task *t2, *next = NULL;
struct cell *super = t->ci->super;
/* Release whatever locks this task held. */ /* Release whatever locks this task held. */
if (!t->implicit) task_unlock(t); if (!t->implicit) task_unlock(t);
/* Loop through the dependencies and add them to a queue if /* Loop through the dependencies and add them to a queue if
they are ready. */ they are ready. */
for (k = 0; k < t->nr_unlock_tasks; k++) { for (int k = 0; k < t->nr_unlock_tasks; k++) {
t2 = t->unlock_tasks[k]; struct task *t2 = t->unlock_tasks[k];
if ((res = atomic_dec(&t2->wait)) < 1) error("Negative wait!"); int res = atomic_dec(&t2->wait);
if (res == 1 && !t2->skip) { if (res < 1) {
if (0 && !t2->implicit && t2->ci->super == super && error("Negative wait!");
(next == NULL || t2->weight > next->weight) && task_lock(t2)) { } else if (res == 1 && !t2->skip) {
if (next != NULL) { scheduler_enqueue(s, t2);
task_unlock(next);
scheduler_enqueue(s, next);
}
next = t2;
} else
scheduler_enqueue(s, t2);
} }
} }
/* Task definitely done. */ /* Task definitely done, signal any sleeping runners. */
if (!t->implicit) { if (!t->implicit) {
t->toc = getticks(); t->toc = getticks();
pthread_mutex_lock(&s->sleep_mutex); pthread_mutex_lock(&s->sleep_mutex);
if (next == NULL) atomic_dec(&s->waiting); atomic_dec(&s->waiting);
pthread_cond_broadcast(&s->sleep_cond); pthread_cond_broadcast(&s->sleep_cond);
pthread_mutex_unlock(&s->sleep_mutex); pthread_mutex_unlock(&s->sleep_mutex);
} }
/* Start the clock on the follow-up task. */ /* Return the next best task. Note that we currently do not
if (next != NULL) next->tic = getticks(); implement anything that does this, as getting it to respect
priorities is too tricky and currently unnecessary. */
/* Return the next best task. */ return NULL;
return next;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment