diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 3a28af4473b6..a52c2d48eed6 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -191,7 +191,9 @@ rust_kernel::release_task_id(rust_task_id id) { void rust_kernel::wakeup_schedulers() { for(size_t i = 0; i < num_threads; ++i) { - threads[i]->lock.signal_all(); + rust_scheduler *sched = threads[i]; + scoped_lock with(sched->lock); + sched->lock.signal_all(); } } diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 098e9e3c131c..a22b3ebc47a1 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -394,7 +394,6 @@ rust_task::start(spawn_fn spawnee_fn, void rust_task::start() { transition(&sched->newborn_tasks, &sched->running_tasks); - sched->lock.signal(); } // Only run this on the rust stack @@ -429,8 +428,6 @@ rust_task::kill() { // Unblock the task so it can unwind. unblock(); - sched->lock.signal(); - LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this); // run_on_resume(rust_unwind_glue); } @@ -551,6 +548,7 @@ rust_task::transition(rust_task_list *src, rust_task_list *dst) { src->remove(this); dst->append(this); state = dst; + sched->lock.signal(); if(unlock) sched->lock.unlock(); } @@ -578,12 +576,9 @@ rust_task::wakeup(rust_cond *from) { (uintptr_t) cond, (uintptr_t) from); A(sched, cond == from, "Cannot wake up blocked task on wrong condition."); - transition(&sched->blocked_tasks, &sched->running_tasks); - I(sched, cond == from); cond = NULL; cond_name = "none"; - - sched->lock.signal(); + transition(&sched->blocked_tasks, &sched->running_tasks); } void @@ -591,7 +586,6 @@ rust_task::die() { I(sched, !lock.lock_held_by_current_thread()); scoped_lock with(lock); transition(&sched->running_tasks, &sched->dead_tasks); - sched->lock.signal(); } void