Re: Futex Stack...

Liste des GroupesRevenir à c arch 
Sujet : Re: Futex Stack...
De : chris.m.thomasson.1 (at) *nospam* gmail.com (Chris M. Thomasson)
Groupes : comp.arch
Date : 28. Mar 2025, 17:55:24
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vs6k9t$35a2q$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 3/25/2025 12:11 AM, Chris M. Thomasson wrote:
This is a little C++20 test using a futex to allow one to wait on a lock-free stack. The main stack logic is in struct ct_stack. Well, can you get to compile and run? Thanks... There is no need for DWCAS here. It uses just XCHG and CMPXCHG.
  My code:
______________________________________
#include <iostream>
#include <thread>
#include <atomic>
#include <algorithm>
#include <cassert>
  #define CT_THREAD_N (42)
#define CT_WORK_N (10000000)

#define CT_WAIT ((ct_node*)0xDEADBEEF)
^^^^^^^^^^^^^^^^^^^^^^^
[...]
Fwiw, I am using CT_WAIT for the C++20 futex to avoid slow-paths. However, this scares me a bit because if the user allocates a node that has that exact address, it will totally break the algorithm. So, I really should create a "stub dummy node" and use its address for the wait condition. Something like this pseudo-code:
static ct_node const g_dummy_wait = { };
Then change CT_WAIT to (&g_dummy_wait). That would eliminate any possibility of that potential error to occur.

Date Sujet#  Auteur
25 Mar 25 * Futex Stack...3Chris M. Thomasson
28 Mar 25 +- Re: Futex Stack...1Chris M. Thomasson
9 Apr 25 `- Re: Futex Stack...1Chris M. Thomasson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal