Sujet : Re: Strange asm generated by GCC...
De : jseigh_es00 (at) *nospam* xemaps.com (jseigh)
Groupes : comp.archDate : 24. Dec 2024, 02:16:08
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vkd20o$1fk7q$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 12/23/24 16:20, Chris M. Thomasson wrote:
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.