File tree 1 file changed +21
-3
lines changed
1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,27 @@ the fences will prevent the operations on `x` from being merged even though we
199
199
know that ` buf ` doesn't overlap with ` x ` (due to Rust aliasing rules). However,
200
200
there exist no intrinsic that's more fine grained than ` compiler_fence ` .
201
201
202
- > ** NOTE:** You * may* need to use a [ ` atomic::fence ` ] [ ] (a memory barrier)
203
- > instead of a ` compiler_fence ` if you expect your API to be used with buffers
204
- > shared between different cores. But this depends on how you design your API.
202
+ ### Don't we need a memory barrier?
203
+
204
+ That depends on the target architecture. In the case of Cortex-M cores, [ AN321]
205
+ says:
206
+
207
+ [ AN321 ] : https://static.docs.arm.com/dai0321/a/DAI0321A_programming_guide_memory_barriers_for_m_profile.pdf
208
+
209
+ > The use of DMB is rarely needed in Cortex-M processors because they do not
210
+ > reorder memory transactions. However, it is needed if the software is to be
211
+ > reused on other ARM processors, especially multi-master systems. For example:
212
+ >
213
+ > - DMA controller configuration. A barrier is required between a CPU memory
214
+ > access and a DMA operation.
215
+ >
216
+ > (..)
217
+
218
+ If your target is a multi-core system then it's very likely that you'll need
219
+ memory barriers.
220
+
221
+ If you do need the memory barrier then you need to use [ ` atomic::fence ` ] instead
222
+ of ` compiler_fence ` .
205
223
206
224
[ `atomic::fence` ] : https://doc.rust-lang.org/core/sync/atomic/fn.fence.html
207
225
You can’t perform that action at this time.
0 commit comments