From 62bc6b51136760b1d4f4b691aaa089bdb9bf0af5 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Sat, 23 Jul 2011 19:03:02 -0700 Subject: Per-thread scheduling. Closes #682. Tasks are spawned on a random thread. Currently they stay there, but we should add task migration and load balancing in the future. This should drammatically improve our task performance benchmarks. --- src/rt/rust_task.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index de6b00acb3f..10ea48f57c2 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -83,7 +83,8 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, pinned_on(-1), local_region(&sched->srv->local_region), _on_wakeup(NULL), - failed(false) + failed(false), + propagate_failure(true) { LOGPTR(sched, "new task", (uintptr_t)this); DLOG(sched, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this); @@ -207,8 +208,8 @@ rust_task::kill() { // Unblock the task so it can unwind. unblock(); - // if (this == sched->root_task) - // sched->fail(); + if (NULL == supervisor && propagate_failure) + sched->fail(); LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this); // run_on_resume(rust_unwind_glue); @@ -229,6 +230,8 @@ rust_task::fail() { supervisor->kill(); } // FIXME: implement unwinding again. + if (NULL == supervisor && propagate_failure) + sched->fail(); failed = true; } @@ -248,6 +251,7 @@ rust_task::unsupervise() " disconnecting from supervisor %s @0x%" PRIxPTR, name, this, supervisor->name, supervisor); supervisor = NULL; + propagate_failure = false; } void @@ -397,8 +401,8 @@ rust_task::free(void *p, bool is_gc) void rust_task::transition(rust_task_list *src, rust_task_list *dst) { - I(sched, !kernel->scheduler_lock.lock_held_by_current_thread()); - scoped_lock with(kernel->scheduler_lock); + I(sched, !sched->lock.lock_held_by_current_thread()); + scoped_lock with(sched->lock); DLOG(sched, task, "task %s " PTR " state change '%s' -> '%s' while in '%s'", name, (uintptr_t)this, src->name, dst->name, state->name); -- cgit 1.4.1-3-g733a5