Skip to content

Commit

Permalink
Merge pull request #9 from betrusted-io/1.74.1-xous-fix-parker
Browse files Browse the repository at this point in the history
park_timeout: remove spurious wait condition
  • Loading branch information
xobs authored Dec 22, 2023
2 parents c1d1190 + d20e2f4 commit 325d29a
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions library/std/src/sys/xous/thread_parking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,14 @@ impl Parker {
// milliseconds to the allowed range.
let millis = usize::max(timeout.as_millis().try_into().unwrap_or(usize::MAX), 1);

let was_timeout = blocking_scalar(
let _was_timeout = blocking_scalar(
ticktimer_server(),
TicktimerScalar::WaitForCondition(self.index(), millis).into(),
)
.expect("failed to send WaitForCondition command")[0]
!= 0;

let state = self.state.swap(EMPTY, Acquire);
if was_timeout && state == NOTIFIED {
// The state was set to NOTIFIED after we returned from the wait
// but before we reset the state. Therefore, a wakeup is on its
// way, which we need to consume here.
// NOTICE: this is a priority hole.
blocking_scalar(
ticktimer_server(),
TicktimerScalar::WaitForCondition(self.index(), 0).into(),
)
.expect("failed to send WaitForCondition command");
}
let _state = self.state.swap(EMPTY, Acquire);
}

pub fn unpark(self: Pin<&Self>) {
Expand Down

0 comments on commit 325d29a

Please sign in to comment.