diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-11-23 14:00:26 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-23 14:00:26 +0100 |
| commit | de95ab264d8ee2bf5ba9c3615ecb1b44e3940694 (patch) | |
| tree | e2c3c531b821a0678033943c3b68581691af5732 /embassy-executor/src | |
| parent | b76631bebe980a8a04db0f07f0c3efb7edaccf2e (diff) | |
| parent | 50c5cc5db64f7ddf8566626f92c0694ac9ad984e (diff) | |
Merge pull request #1073 from embassy-rs/revert-riscv-race
fix: revert race condition introduced for riscv
Diffstat (limited to 'embassy-executor/src')
| -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 | } |
