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

@ -55,11 +55,19 @@ impl Executor {
unsafe { unsafe {
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.
// if there is work to do, loop back to polling critical_section::with(|_| {
if !SIGNAL_WORK_THREAD_MODE.fetch_and(false, Ordering::SeqCst) { // if there is work to do, loop back to polling
core::arch::asm!("wfi"); // 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");
}
});
// if an interrupt occurred while waiting, it will be serviced here
} }
} }
} }