Skip to content

Commit 70677bb

Browse files
committed
perf(port_arm_m): surround yield_cpu with compiler barriers
1 parent 89c3816 commit 70677bb

File tree

1 file changed

+6
-0
lines changed
  • src/r3_port_arm_m/src/threading

1 file changed

+6
-0
lines changed

src/r3_port_arm_m/src/threading/imp.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ impl State {
169169
}
170170

171171
pub unsafe fn yield_cpu<Traits: PortInstance>(&'static self) {
172+
// Ensure preceding memory operations are visible to the PendSV handler
173+
compiler_fence(Ordering::Release);
174+
172175
// Safety: See `use_port!`
173176
cortex_m::peripheral::SCB::set_pendsv();
174177

175178
// Technically this DSB isn't required for correctness, but ensures
176179
// PendSV is taken before the next operation.
177180
cortex_m::asm::dsb();
181+
182+
// Ensure the PendSV handler's memory operations are visible to us
183+
compiler_fence(Ordering::Acquire);
178184
}
179185

180186
pub unsafe fn exit_and_dispatch<Traits: PortInstance>(

0 commit comments

Comments
 (0)