Skip to content

Commit 6fbef06

Browse files
committed
kmc-solid: Synchronize with the read when sending a joining task ID to a joinee
1 parent 304c6dc commit 6fbef06

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

library/std/src/sys/itron/thread.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ impl Thread {
151151
// Since the parent might drop `*inner` and terminate us as
152152
// soon as it sees `JOIN_FINALIZE`, the release ordering
153153
// must be used in the above `swap` call.
154+
//
155+
// To make the task referred to by `parent_tid` visible, we
156+
// must use the acquire ordering in the above `swap` call.
154157

155158
// [JOINING → JOIN_FINALIZE]
156159
// Wake up the parent task.
@@ -218,11 +221,15 @@ impl Thread {
218221

219222
let current_task = current_task as usize;
220223

221-
match inner.lifecycle.swap(current_task, Ordering::Acquire) {
224+
match inner.lifecycle.swap(current_task, Ordering::AcqRel) {
222225
LIFECYCLE_INIT => {
223226
// [INIT → JOINING]
224227
// The child task will transition the state to `JOIN_FINALIZE`
225228
// and wake us up.
229+
//
230+
// To make the task referred to by `current_task` visible from
231+
// the child task's point of view, we must use the release
232+
// ordering in the above `swap` call.
226233
loop {
227234
expect_success_aborting(unsafe { abi::slp_tsk() }, &"slp_tsk");
228235
// To synchronize with the child task's memory accesses to

0 commit comments

Comments
 (0)