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-06-21 15:10:55 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-06-27 09:58:39 -0700
commit4d99bf9af2107523c01566968e889c4f1a5de49e (patch)
tree8d7fb27687d58be9bd8f6f907b914da4e76fced3 /src/rt/rust_task.cpp
parentcb00befff050e69565d2862b458bbd56f20b7cd3 (diff)
downloadrust-4d99bf9af2107523c01566968e889c4f1a5de49e.tar.gz
rust-4d99bf9af2107523c01566968e889c4f1a5de49e.zip
Added some locking to ports to prevent the case where two threads simultaneously wake up a task blocked on a certain port.
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index f42f40510bd..c26e793b979 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -170,10 +170,7 @@ rust_task::start(uintptr_t spawnee_fn,
     ctx.call((void *)task_start_wrapper, a, sp);
 
     yield_timer.reset(0);
-    {
-        scoped_lock sync(dom->scheduler_lock);
-        transition(&dom->newborn_tasks, &dom->running_tasks);
-    }
+    transition(&dom->newborn_tasks, &dom->running_tasks);
 }
 
 void
@@ -408,6 +405,7 @@ rust_task::free(void *p, bool is_gc)
 
 void
 rust_task::transition(rust_task_list *src, rust_task_list *dst) {
+    scoped_lock sync(dom->scheduler_lock);
     DLOG(dom, task,
          "task %s " PTR " state change '%s' -> '%s' while in '%s'",
          name, (uintptr_t)this, src->name, dst->name, state->name);
@@ -424,10 +422,7 @@ rust_task::block(rust_cond *on, const char* name) {
     A(dom, cond == NULL, "Cannot block an already blocked task.");
     A(dom, on != NULL, "Cannot block on a NULL object.");
 
-    {
-        scoped_lock sync(dom->scheduler_lock);
-        transition(&dom->running_tasks, &dom->blocked_tasks);
-    }
+    transition(&dom->running_tasks, &dom->blocked_tasks);
     cond = on;
     cond_name = name;
 }
@@ -439,10 +434,7 @@ rust_task::wakeup(rust_cond *from) {
                         (uintptr_t) cond, (uintptr_t) from);
     A(dom, cond == from, "Cannot wake up blocked task on wrong condition.");
 
-    {
-        scoped_lock sync(dom->scheduler_lock);
-        transition(&dom->blocked_tasks, &dom->running_tasks);
-    }
+    transition(&dom->blocked_tasks, &dom->running_tasks);
     I(dom, cond == from);
     cond = NULL;
     cond_name = "none";
@@ -450,7 +442,6 @@ rust_task::wakeup(rust_cond *from) {
 
 void
 rust_task::die() {
-    scoped_lock sync(dom->scheduler_lock);
     transition(&dom->running_tasks, &dom->dead_tasks);
 }