about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-07-23 19:03:02 -0700
committerEric Holk <eholk@mozilla.com>2011-07-28 10:47:28 -0700
commit62bc6b51136760b1d4f4b691aaa089bdb9bf0af5 (patch)
treebd4787e8bd4eed7b3ca7b3d99ece0fc75ae444fa /src/rt/rust_task.cpp
parentb51f5c395cc3458e428159b908ca95b1777e66e2 (diff)
downloadrust-62bc6b51136760b1d4f4b691aaa089bdb9bf0af5.tar.gz
rust-62bc6b51136760b1d4f4b691aaa089bdb9bf0af5.zip
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.
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp14
1 files changed, 9 insertions, 5 deletions
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);