fix: revert race condition introduced for riscv

This commit is contained in:
Ulf Lilleengen 2022-11-23 13:17:05 +01:00
parent 2fa2c1a6fe
commit 50c5cc5db6
Failed to extract signature

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.
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
} }
} }
} }