An introduction to lockless algorithms
An introduction to lockless algorithms
Posted Feb 20, 2021 7:17 UTC (Sat) by pbonzini (subscriber, #60935)In reply to: An introduction to lockless algorithms by kurogane
Parent article: An introduction to lockless algorithms
Yes, the point is that there might be reordering unless the store and load have release and acquire semantics respectively.
In theory the reordering could be on both sides, in practice (except on the Alpha) only the release side might be assigning a.x after message. Even on non-Alpha processors you need to inform the compiler not to do any reordering.
However you could have for example "ready=1" on the producer side and "if (ready) printk("%x", a.x)" on the consumer side. In that case both sides need to be protected against reordering at the processor level (in addition to the compiler level).
