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

holy crap, this actually seems to work... cleaning up the formatting and puting it out there.

parent a4ecb68d
Branches
Tags
1 merge request!60Parallel scheduler
......@@ -1291,7 +1291,8 @@ void *runner_main(void *data) {
runner_dograv_down(r, t->ci);
break;
case task_type_rewait:
for (struct task *t2 = (struct task *)t->ci; t2 != (struct task *)t->cj; t2++) {
for (struct task *t2 = (struct task *)t->ci;
t2 != (struct task *)t->cj; t2++) {
for (k = 0; k < t2->nr_unlock_tasks; k++)
atomic_inc(&t2->unlock_tasks[k]->wait);
}
......
......@@ -888,21 +888,23 @@ void scheduler_start(struct scheduler *s, unsigned int mask) {
/* Store the mask */
s->mask = mask;
/* Clear all the waits and rids. */
// tic = getticks();
for (int k = 0; k < s->nr_tasks; k++) {
s->tasks[k].wait = 0;
s->tasks[k].rid = -1;
}
/* Enqueue a set of extraenous tasks to set the task waits. */
struct task rewait_tasks[s->nr_queues];
const int waiting_old = s->waiting; // Remember that engine_launch may fiddle with this value.
const int waiting_old =
s->waiting; // Remember that engine_launch may fiddle with this value.
for (int k = 0; k < s->nr_queues; k++) {
rewait_tasks[k].type = task_type_rewait;
rewait_tasks[k].ci = (struct cell *)&s->tasks[k * nr_tasks / s->nr_queues];
rewait_tasks[k].cj = (struct cell *)&s->tasks[(k + 1) * nr_tasks / s->nr_queues];
rewait_tasks[k].cj =
(struct cell *)&s->tasks[(k + 1) * nr_tasks / s->nr_queues];
rewait_tasks[k].skip = 0;
rewait_tasks[k].wait = 0;
rewait_tasks[k].weight = 1;
......@@ -911,7 +913,7 @@ void scheduler_start(struct scheduler *s, unsigned int mask) {
scheduler_enqueue(s, &rewait_tasks[k]);
pthread_cond_broadcast(&s->sleep_cond);
}
/* Wait for the rewait tasks to have executed. */
pthread_mutex_lock(&s->sleep_mutex);
while (s->waiting > waiting_old) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment