Sujet : Re: Wait-free Hazard Pointers Using Std Atomics
De : chris.m.thomasson.1 (at) *nospam* gmail.com (Chris M. Thomasson)
Groupes : comp.lang.c++Date : 28. May 2025, 23:34:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <101830t$3faku$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 5/26/2025 2:58 PM, jseigh wrote:
and asymmetric memory barriers of course.
https://threadnought.wordpress.com/2025/05/26/wait-free-hazard-pointers- using-std-atomics/
Looks like it runs faster without the conditional branch.
Not sure it's a new idea. The only wait-free version of hazard pointers
I've seen so far involves a storage to storage move instruction which
might not be available on all platforms.
Joe Seigh
Actually wrt:
_______________
hz_ptr.store(INDETERMINATE, std::memory_order_relaxed);
T* local = ptr.load(std::memory_order_relaxed);
hz_ptr.store(local, std::memory_order_relaxed);
_______________
For some damn reason, it kind of reminds me of an older way to use only single word exchange to push into a lock-free stack.
Iirc, something like this pseudo code for push:
_____________
cur->next = WAIT_STATE;
node* prev = exchange(head, cur);
cur->next = prev;
_____________
There is a "window" in there where cur->next will be WAIT_STATE. So, when a thread iterating the list, say after pop all, flush, it can do a couple of spins or do something else during iteration on a cur->next being in WAIT_STATE. It's a way to get exchange on push and pop of a stack.
The window is very small. I am having trouble finding on this group where I posted about it before in a working program...