2 ms·
Peterson algorithm is broken on x86 if implemented with just volatiles. The compiler will not emit the required fences. On x86 if everything that can be potent
by gpderetta 5y ago
Peterson algorithm is broken on x86 if implemented with just volatiles. The compiler will not emit the required fences.
On x86 if everything that can be potentially shared is volatile, you may get away with it if you only need acquire/release, but in practice not everything being shared are not going to be volatile. For example if you implement a spsc queue only with volatile operations and use it to send a pointer to a non volatile object to another thread, the consumer might see a non initialized object.