14
votes

On ARM architecture, unfortunately I don't know exactly what chip it is, is a 32 bit int read/write atomic?

Is there any sort of guarantees about reads/writes to basic types?

1
If that int is suitably aligned (to 4 bytes), I guess that, like on most 32 bits processors, the write is somehow atomic. However, the real question is the memory model (notably in multi-core situations : cache coherency, etc.).Basile Starynkevitch
Even in if there is no cache coherency, the read/write to main memory would still be atomic (but delayed)Johan Kotlinski
@BasileStarynkevitch yes memory model is a good point, but I only have on ARM cpu with one core.Tony The Lion
Yes, it is atomic (except perhaps in a packed struct). See my full answer, including for all other data types, here: stackoverflow.com/a/52785864/4561887.Gabriel Staples

1 Answers

12
votes

It should be atomic, EXCEPT if that int is stored on a non-aligned address.