3 ms·
> It is much easier to do it at design time Is it? I always worked the second way (starting from seq_cst and then when the core design matured enough and didn'
by jcelerier 3y ago
> It is much easier to do it at design time
Is it? I always worked the second way (starting from seq_cst and then when the core design matured enough and didn't change for a few months, trying to see what could actually be relaxed). I'd be very afraid that in the first case, you start with say relaxed semantics somewhere, them you change the design because the requirements changed, and now you have to go again through all the atomic operations to make sure the assumptions all still hold.
- jamesmunns 3y agoBack when this post was written, I would have agreed with you. But Mara's book makes a good case for this: https://marabos.nl/atomics/memory-ordering.html#common-misconceptions https://marabos.nl/atomics/memory-ordering.html#common-misco... More importantly, when reading code, SeqCst basically tells the reader: "this operation depends on the total order of every single SeqCst operation in the program," which is an incredibly far-reaching claim. The same code would likely be easier to review and verify if it used weaker memory ordering instead, if possible... It is advisable to see SeqCst as a warning sign.
- gpderetta 3y agoIf you change the design of a lock free algo you very likely have to go through all the atomic operations to make sure that all assumptions hold anyway.