Sure, I'd be happy to summarize the guarantees that x86 and ARM make about memory access!
x86 Memory Model:
The x86 memory model provides strong memory ordering guarantees. This means that the order of memory accesses (reads and writes) made by a single processor is always preserved, and the order of memory accesses made by different processors is also preserved in most cases. Specifically, the x86 memory model supports a total memory ordering, which guarantees that:
- All memory accesses made by a single processor are completed in program order. This means that if a processor executes a sequence of memory accesses, those accesses will be observed by other processors in the same order.
- Memory accesses made by different processors are observed in a consistent order. This means that if one processor writes to a memory location and another processor reads from that location, the reading processor will always see the value written by the writing processor, and not some intermediate value.
- Loads are always ordered before stores to the same memory location. This means that if a processor performs a load from a memory location and then performs a store to the same location, any other processor that reads from that location will see the load before the store.
ARM Memory Model:
The ARM memory model is more relaxed than the x86 memory model. ARM provides a number of different memory ordering options, which can be configured by software. The most commonly used memory ordering options are:
- Normal memory accesses: These accesses are ordered according to the program order of each processor. However, there is no guarantee about the order in which these accesses will be observed by other processors.
- Load-Acquire and Store-Release accesses: These accesses provide stronger ordering guarantees than normal memory accesses. A Load-Acquire access ensures that all previous memory accesses (both loads and stores) are completed before the load is performed. A Store-Release access ensures that all subsequent memory accesses (both loads and stores) are not performed until after the store is completed.
- Load-Exclusive and Store-Exclusive accesses: These accesses provide even stronger ordering guarantees than Load-Acquire and Store-Release accesses. A Load-Exclusive access ensures that all previous memory accesses are completed before the load is performed, and that no other processor can perform a memory access to the same location until the load is completed. A Store-Exclusive access ensures that all subsequent memory accesses are not performed until after the store is completed, and that no other processor can perform a memory access to the same location until the store is completed.
In summary, the x86 memory model provides strong memory ordering guarantees, while the ARM memory model provides more flexible memory ordering options. Depending on the application, one memory model may be more suitable than the other.