🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to write a semaphore with futexes

#830
From: Chris M. Thomasson
Date: Wed, 11 Nov 2026 23:05
15 lines
2143 bytes
On 11/11/2026 2:47 PM, Bonita Montero wrote:
> Am 11.11.2026 um 23:12 schrieb Chris M. Thomasson:
> 
>> I see. A fun failure on a sem_wait is EINTR.
> 
> That's not a out of recources error and it is recoverable.

Its scary though when people fail to know about it.

About resources, if the futex is using a multex for the slow path it 
would never run out of resources simply because they are created up 
front before anything in the user program runs, or a large one in the 
kernel at os boot. For a futex slow path they, on some impls I have 
seen, hash the address into an index for a kernel object, a wait queue 
iirc. Akin to the multex hashing addresses into mutexes.
Technical Details
Message-ID: <11d2sca$3fn5d$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11cvher$2ahke$1@raubtier-asyl.eternal-september.org> <11d02gm$2h8g0$1@dont-email.me> <11d145g$2qlhs$1@raubtier-asyl.eternal-september.org> <11d2p9c$3eke4$1@dont-email.me> <11d2r97$3f9sa$2@raubtier-asyl.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!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: How to write a semaphore with futexes
Date: Wed, 11 Nov 2026 15:05:43 -0800
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <11d2sca$3fn5d$1@dont-email.me>
References: <11cvher$2ahke$1@raubtier-asyl.eternal-september.org>
 <11d02gm$2h8g0$1@dont-email.me>
 <11d145g$2qlhs$1@raubtier-asyl.eternal-september.org>
 <11d2p9c$3eke4$1@dont-email.me>
 <11d2r97$3f9sa$2@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 11 Nov 2026 23:05:47 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3660973"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/raMHtOaXm3EZmjrCDkkSTJs1vobmiaB8="; posting-host="11f9b5e6e37d99a5324f29576617ac26"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:w2v0MgaE4xToWKCHKOPiBZ6ovi0= sha256:A4Flo8XZspYT/11SapaSLN2MJqMionFQjr7VSGX+7Fg=
	sha1:lHPzj5rRUE6CNd1fNYcrfB/4aFQ= sha256:USIuoiWSAIlYno1m48i3oZUDdSnIZ1A891eaPt1sC0M=
Content-Language: en-US
In-Reply-To: <11d2r97$3f9sa$2@raubtier-asyl.eternal-september.org>