For example, in the standards C11 and C ++ 11 , functions 6 types of memory barriers: http://en.cppreference.com/w/cpp/atomic/memory_order
- memory_order_relaxed
- memory_order_consume
- memory_order_acquire
- memory_order_release
- memory_order_acq_rel
- memory_order_seq_cst
The directions in which the compiler can reorder instructions are determined, as well as which processor instructions require insertion to limit reordering in the processor pipeline. For example, the first five barriers affect only the compiler, but they do not generate any CPU instructions (no S/L/ MFENCE), because in x86, get-release semantics are provided automatically.
How many types of memory barriers are available in Java? Or are there only 2 types?
- All reordering allowed
- All reordering prohibited
source
share