about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorTomoaki Kawada <kawada@kmckk.co.jp>2022-12-12 13:44:06 +0900
committerTomoaki Kawada <kawada@kmckk.co.jp>2022-12-12 14:36:17 +0900
commit6fbef06f26b038c97578dfb8a577e68ec0189f37 (patch)
tree137d9c4263f72a4a55f311c075c007714dd0809f /library/std/src/sys
parent304c6dcaed94ce573755123a7979dd8f2bde7b02 (diff)
downloadrust-6fbef06f26b038c97578dfb8a577e68ec0189f37.tar.gz
rust-6fbef06f26b038c97578dfb8a577e68ec0189f37.zip
kmc-solid: Synchronize with the read when sending a joining task ID to a joinee
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/itron/thread.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/library/std/src/sys/itron/thread.rs b/library/std/src/sys/itron/thread.rs
index 68eebef1b20..535703be33f 100644
--- a/library/std/src/sys/itron/thread.rs
+++ b/library/std/src/sys/itron/thread.rs
@@ -151,6 +151,9 @@ impl Thread {
                     // Since the parent might drop `*inner` and terminate us as
                     // soon as it sees `JOIN_FINALIZE`, the release ordering
                     // must be used in the above `swap` call.
+                    //
+                    // To make the task referred to by `parent_tid` visible, we
+                    // must use the acquire ordering in the above `swap` call.
 
                     // [JOINING → JOIN_FINALIZE]
                     // Wake up the parent task.
@@ -218,11 +221,15 @@ impl Thread {
 
         let current_task = current_task as usize;
 
-        match inner.lifecycle.swap(current_task, Ordering::Acquire) {
+        match inner.lifecycle.swap(current_task, Ordering::AcqRel) {
             LIFECYCLE_INIT => {
                 // [INIT → JOINING]
                 // The child task will transition the state to `JOIN_FINALIZE`
                 // and wake us up.
+                //
+                // To make the task referred to by `current_task` visible from
+                // the child task's point of view, we must use the release
+                // ordering in the above `swap` call.
                 loop {
                     expect_success_aborting(unsafe { abi::slp_tsk() }, &"slp_tsk");
                     // To synchronize with the child task's memory accesses to