mirror of
https://github.com/rust-lang/rust
synced 2024-10-17 05:53:41 +00:00
kmc-solid: Synchronize with the read when sending a joining task ID to a joinee
This commit is contained in:
parent
304c6dcaed
commit
6fbef06f26
|
@ -151,6 +151,9 @@ pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<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 @@ pub fn join(self) {
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue