Sujet : Re: Futexes ain't fast
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.c++Date : 26. Sep 2024, 18:44:02
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vd46gr$ajf8$1@raubtier-asyl.eternal-september.org>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
Am 26.09.2024 um 19:40 schrieb Chris M. Thomasson:
Basically right. Think of hitting a slow path (before resorting to the kernel), then trying to spin a couple of times in user space before we have to hit a kernel call. Akin to a adaptive mutex. If we can avoid a kernel call, well, go ahead and try a couple of times...
Adaptive mutexes often don't make any sense. The locking-frequency has
to be high and the locked-interval needs to be very short to make spin-
ning likely to succeed. That's both not often.
Actually, there is a "method" to do this even with a simple mutex via try_lock. ...
I don't know what try_lock is good for. I've never seen someone using
try_lock. If you need to lock sth. you usually haven't an alternative
to locking.