From 6657e729de2d4544d4f014091ef05878937895dc Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 29 Jul 2011 21:43:22 -0700 Subject: [PATCH] Lock the new task's scheduler when creating a task Previously we were locking the spawning task's scheduler. I couldn't see that that was protecting anything. The newborn_task list in the new task's scheduler though was unprotected from concurrent access. So now we're locking the new task's scheduler. --- src/rt/rust_kernel.cpp | 4 +++- src/rt/rust_upcall.cpp | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 1eeb9b2c0188..7ff2f16a2282 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -135,7 +135,9 @@ int rust_kernel::start_task_threads() rust_task * rust_kernel::create_task(rust_task *spawner, const char *name) { - return threads[rand(&rctx) % num_threads]->create_task(spawner, name); + rust_scheduler *thread = threads[rand(&rctx) % num_threads]; + scoped_lock with(thread->lock); + return thread->create_task(spawner, name); } void rust_kernel::wakeup_schedulers() { diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 048be072e12e..57512fd8c2ae 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -526,7 +526,6 @@ extern "C" CDECL rust_task * upcall_new_task(rust_task *spawner, rust_vec *name) { // name is a rust string structure. LOG_UPCALL_ENTRY(spawner); - scoped_lock with(spawner->sched->lock); rust_task *task = spawner->kernel->create_task(spawner, (const char *)name->data); task->ref();