๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++
Article #42

Re: Consequential RCU

#42
From: Chris M. Thomasson
Date: Thu, 08 Oct 2026 21:20
116 lines
4578 bytes
On 10/8/2026 12:19 PM, Chris M. Thomasson wrote:
> On 10/7/2026 8:55 PM, Bonita Montero wrote:
>> Am 07.10.2026 um 22:17 schrieb Chris M. Thomasson:
>>
>>> ย thread_local shared_obj<leaps_set, sobj_mode::All> pLeaps;
>>
>>> ? So, are you taking a reference to something the thread does not own?
>> Like with RCU no thread owns the data once its published since it is 
>> read only.
> 
> Well, your work sure seems to act like a proxy. But it uses CAS and 
> futex. Therefore its out of scope with anything lock-free.

For instance. Take my most recent post "CAS free Proxy Collector..."

https://pastebin.com/raw/CYZ78gVj

Notice how it can allow lock-free iterations of a lock-free stack that 
does not use any DWCAS, no ABA? How can we use yours for the same thing? 
No lock, no futex, 100% lock-free etc? Heck on systems that don't use 
LL/SC loops for fetch and add, well its wait-free on the fast path. For 
instance:

// you're basic lock-free stack...
// well, minus ABA counter and DWCAS of course!  ;^)
class ct_stack
{
     std::atomic<ct_node*> m_head;


public:
     ct_stack() : m_head(nullptr)
     {

     }


public:
     void push(ct_node* n)
     {
         ct_node* head = m_head.load(std::memory_order_relaxed);

         do
         {
             n->m_next.store(head, std::memory_order_relaxed);
         }

         while (! m_head.compare_exchange_weak(
             head,
             n,
             std::memory_order_release));
     }


     ct_node* flush()
     {
         return m_head.exchange(nullptr, std::memory_order_acquire);
     }


     ct_node* get_head()
     {
         return m_head.load(std::memory_order_acquire);
     }


     ct_node* pop()
     {
         ct_node* head = m_head.load(std::memory_order_acquire);
         ct_node* xchg;

         do
         {
             if (! head) return nullptr;

             xchg = head->m_next.load(std::memory_order_relaxed);
         }

         while (!m_head.compare_exchange_weak(
             head,
             xchg,
             std::memory_order_acquire));

         return head;
     }
};



With iterations with heavy read and some write activity.

// Reader threads
// Iterates through the lock free stack
void ct_thread_reader(ct_shared& shared)
{
     // iterate the lockfree stack
     for (unsigned long i = 0; i < ct_reader_iters_n; ++i)
     {
         ct_proxy_collector::collector& c = shared.m_proxy_gc.acquire();

         ct_node* n = shared.m_stack.get_head();

         while (n)
         {
             // need to add in some processing...
             // std::this_thread::yield();

             n = n->m_next.load(std::memory_order_relaxed);
         }

         shared.m_proxy_gc.release(c);
     }
}

Ideally the shared.m_stack should have a lot of nodes to make it worth 
while...
Technical Details
Message-ID: <11a91ft$7mi3$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <118f4vv$3plsv$1@dont-email.me> <11a0l38$150m3$1@raubtier-asyl.eternal-september.org> <11a0odn$16c2e$1@dont-email.me> <11a0tf5$18frd$1@raubtier-asyl.eternal-september.org> <11a4i3l$2i092$3@dont-email.me> <11a5fpa$2sm77$1@raubtier-asyl.eternal-september.org> <11a5h9j$2t9s2$1@raubtier-asyl.eternal-september.org> <11a69ct$377dl$1@dont-email.me> <11a7478$3fl36$1@raubtier-asyl.eternal-september.org> <11a8qcg$4uo1$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.lang.c++
Subject: Re: Consequential RCU
Date: Thu, 8 Oct 2026 14:20:57 -0700
Organization: A noiseless patient Spider
Lines: 116
Message-ID: <11a91ft$7mi3$1@dont-email.me>
References: <118f4vv$3plsv$1@dont-email.me>
 <11a0l38$150m3$1@raubtier-asyl.eternal-september.org>
 <11a0odn$16c2e$1@dont-email.me>
 <11a0tf5$18frd$1@raubtier-asyl.eternal-september.org>
 <11a4i3l$2i092$3@dont-email.me>
 <11a5fpa$2sm77$1@raubtier-asyl.eternal-september.org>
 <11a5h9j$2t9s2$1@raubtier-asyl.eternal-september.org>
 <11a69ct$377dl$1@dont-email.me>
 <11a7478$3fl36$1@raubtier-asyl.eternal-september.org>
 <11a8qcg$4uo1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 08 Oct 2026 21:21:01 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="252483"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19Ep240kw7iwFgRdAVZgSLKM26TdvScjAc="; posting-host="f2e7a3cc611efc61e65025e165a4acf9"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:trVVeovB49LvJ3ufH42gdxo6Fsg= sha256:ZL7OeguUt2rpeqZo45rR91m+nn0/meBbNP/Jv6JPLPg=
	sha1:vjP8q1Vp70GRwXtk7wO0YnB9kqo= sha256:fp7s9GmtrMMk4zUqHIK9l42TK8Y1pBHT9HtCQQVFIJI=
In-Reply-To: <11a8qcg$4uo1$1@dont-email.me>
Content-Language: en-US