about summary refs log tree commit diff
path: root/src/rt/rust_kernel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rt/rust_kernel.cpp')
-rw-r--r--src/rt/rust_kernel.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 1eeb9b2c018..7ff2f16a228 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() {