Merge pull request #1073 from embassy-rs/revert-riscv-race

fix: revert race condition introduced for riscv
This commit is contained in:
Dario Nieuwenhuis 2022-11-23 14:00:26 +01:00 committed by GitHub
commit de95ab264d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,10 +56,18 @@ impl Executor {
self.inner.poll(); self.inner.poll();
// we do not care about race conditions between the load and store operations, interrupts // we do not care about race conditions between the load and store operations, interrupts
//will only set this value to true. //will only set this value to true.
critical_section::with(|_| {
// if there is work to do, loop back to polling // if there is work to do, loop back to polling
if !SIGNAL_WORK_THREAD_MODE.fetch_and(false, Ordering::SeqCst) { // TODO can we relax this?
if SIGNAL_WORK_THREAD_MODE.load(Ordering::SeqCst) {
SIGNAL_WORK_THREAD_MODE.store(false, Ordering::SeqCst);
}
// if not, wait for interrupt
else {
core::arch::asm!("wfi"); core::arch::asm!("wfi");
} }
});
// if an interrupt occurred while waiting, it will be serviced here
} }
} }
} }