🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Fwd: futexes vs. system semaphores

#1139
From: Chris M. Thomasson
Date: Fri, 04 Dec 2026 23:24
45 lines
2587 bytes
On 12/4/2026 3:08 PM, Ross Finlayson wrote:
[...]
> The other day or this morning on the video pile there's
> this Leahy on "Lightning Talk: I'm Not Unreasonable for
> Expecting Functions to Return", where he points out a story
> about learning that io_uring was un-reliable.

I actually feel like making a real test for Bonita futex semaphore. 
Basically use it as a mutex. Humm... His code is:

struct FtxSema
{
     FtxSema(bool initial);
     void release();
     void acquire();
     atomic_int m_ftx;
};

FtxSema::FtxSema(bool initial) :
     m_ftx((int)initial)
{}

void FtxSema::release()
{
     m_ftx = 1;
     m_ftx.notify_one();
}

void FtxSema::acquire()
{
     for (int ftx = m_ftx; ; )
         if (ftx)
             if (m_ftx.compare_exchange_strong(ftx, 0))
                 return;
             else
                 continue;
         else
         {
             m_ftx.wait(0);
             ftx = m_ftx;
         }
}


Technical Details
Message-ID: <11evi48$25mm2$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11duih8$sm6c$1@raubtier-asyl.eternal-september.org> <11duq79$vfpt$1@raubtier-asyl.eternal-september.org> <11er4jp$10h0$1@raubtier-asyl.eternal-september.org> <11esnho$s9c7$2@dont-email.me> <11eso4p$sn9c$1@raubtier-asyl.eternal-september.org> <11eveqi$24221$1@dont-email.me> <11evgbi$24qkv$1@dont-email.me> <uB6cnR35nvtk2o72nZ2dnZfqnPidnZ2d@giganews.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!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: Fwd: futexes vs. system semaphores
Date: Fri, 4 Dec 2026 15:24:51 -0800
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <11evi48$25mm2$1@dont-email.me>
References: <11duih8$sm6c$1@raubtier-asyl.eternal-september.org>
 <11duq79$vfpt$1@raubtier-asyl.eternal-september.org>
 <11er4jp$10h0$1@raubtier-asyl.eternal-september.org>
 <11esnho$s9c7$2@dont-email.me>
 <11eso4p$sn9c$1@raubtier-asyl.eternal-september.org>
 <11eveqi$24221$1@dont-email.me> <11evgbi$24qkv$1@dont-email.me>
 <uB6cnR35nvtk2o72nZ2dnZfqnPidnZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 04 Dec 2026 23:24:56 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2284226"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/HygWmr8WUL+2W1FuahHPnLUwL5Lg7QIs="; posting-host="b19a3c9bc26d9213a9f72d10babaa512"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:YVLrX7+jnyZOlqxjJiBfRf/ZRKM= sha256:SAhXxz3PWF6+UD30gdAAxHVEw1/dOh7M3K4HaAEHIJk=
	sha1:flI+RaBhgL1wigAxOFzz7qWqy1w= sha256:/cnc9WbxPrVQSK30lpr2Tf4GMLcJAiF7+dZZKdkz1wg=
Content-Language: en-US
In-Reply-To: <uB6cnR35nvtk2o72nZ2dnZfqnPidnZ2d@giganews.com>