Electronics > Microcontrollers
32F417 / ARM32: which variables are atomic?
peter-h:
Fairly obviously it must be
boolean (which GCC implements as an int, I think)
8 bit ints
16 bit ints
32 bit ints
NOT 64 bit variables (these will be accessed as at least two goes).
What about single floats?
The more tricky case is that the 32F4 supports unaligned variables, transparently. AFAIK GCC does not assume this and aligns them. I don't use packed structs, but somebody working on this project one day might. I am 99% sure that an unaligned 32 bit variable access will not allow interrupts (therefore RTOS switching) in between the two hardware accesses, but is this right? I would expect DMA can jump in though!
abyrvalg:
Technically, LDRD/STRD can access 64 bits uninterrupted, but there is no way (except asm of course) to force the compiler to use it.
peter-h:
I am surprised that all my guesses in post #1 were correct ;)
On a slightly different tack, could one achieve an atomic write of say 20 bytes with memory-memory DMA?
gf:
--- Quote from: peter-h on March 27, 2023, 02:48:58 pm ---The more tricky case is that the 32F4 supports unaligned variables, transparently. AFAIK GCC does not assume this
--- End quote ---
Doesn't option -munaligned-access enable that?
peter-h:
How would that change whether a memory access is atomic or not, on a CPU which supports unaligned access.
On a slightly different tack, could one achieve an atomic write of say 20 bytes with memory-memory DMA?
Navigation
[0] Message Index
[#] Next page
Go to full version