Liste des Groupes | Revenir à cl c++ |
On 5/26/2025 2:58 PM, jseigh wrote:Push may wait-free but pop isn't event lock-free.and asymmetric memory barriers of course.Actually wrt:
>
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
_______________
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...
Les messages affichés proviennent d'usenet.