Liste des Groupes | Revenir à c arch |
On 12/23/2024 5:16 PM, jseigh wrote:Actually, can the acquire be relaxed into a consume?On 12/23/24 16:20, Chris M. Thomasson wrote:Right. We want the release right before we atomically introduce the node into the stack. For the pop, we can load the head and do an acquire wrt the loop. load the next node in said loop, do the CAS. The success part of the CAS can be a relaxed, the failure would need an another acquire?
>>>
Wrt a traditional lock-free stack, I think the store can use relaxed for the success path of a CAS.
For pushing onto a stack, you want release. For popping from a stack
you want acquire.
>
You are probably ok using relaxed loading the old value. It's not
real clear how aggressive the compiler is allowed to be with relaxed
loads and stores. To be super safe, you might want to add acquire
to all your cas loops.
>
I would just stick with the compare_exchange w/ 1 memory order
parameter. The success/fail form is just confusing, the fail
parameter doesn't do anything.
>
>
Les messages affichés proviennent d'usenet.