diff options
| author | Ulf Lilleengen <[email protected]> | 2022-11-23 13:17:05 +0100 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-11-23 13:17:05 +0100 |
| commit | 50c5cc5db64f7ddf8566626f92c0694ac9ad984e (patch) | |
| tree | 5da817b1b5428af95199ed635ca618232769429c /embassy-executor | |
| parent | 2fa2c1a6fe9c79f11f7382a63ba6a13fe1bae1be (diff) | |
fix: revert race condition introduced for riscv
Diffstat (limited to 'embassy-executor')
| -rw-r--r-- | embassy-executor/src/arch/riscv32.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/embassy-executor/src/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs index 76eb8b114..2a4b006da 100644 --- a/embassy-executor/src/arch/riscv32.rs +++ b/embassy-executor/src/arch/riscv32.rs | |||
| @@ -55,11 +55,19 @@ impl Executor { | |||
| 55 | unsafe { | 55 | unsafe { |
| 56 | self.inner.poll(); | 56 | self.inner.poll(); |
| 57 | // we do not care about race conditions between the load and store operations, interrupts | 57 | // we do not care about race conditions between the load and store operations, interrupts |
| 58 | // will only set this value to true. | 58 | //will only set this value to true. |
| 59 | // if there is work to do, loop back to polling | 59 | critical_section::with(|_| { |
| 60 | if !SIGNAL_WORK_THREAD_MODE.fetch_and(false, Ordering::SeqCst) { | 60 | // if there is work to do, loop back to polling |
| 61 | core::arch::asm!("wfi"); | 61 | // TODO can we relax this? |
| 62 | } | 62 | if SIGNAL_WORK_THREAD_MODE.load(Ordering::SeqCst) { |
| 63 | SIGNAL_WORK_THREAD_MODE.store(false, Ordering::SeqCst); | ||
| 64 | } | ||
| 65 | // if not, wait for interrupt | ||
| 66 | else { | ||
| 67 | core::arch::asm!("wfi"); | ||
| 68 | } | ||
| 69 | }); | ||
| 70 | // if an interrupt occurred while waiting, it will be serviced here | ||
| 63 | } | 71 | } |
| 64 | } | 72 | } |
| 65 | } | 73 | } |
