Sujet : Re: Futexes ain't fast
De : chris.m.thomasson.1 (at) *nospam* gmail.com (Chris M. Thomasson)
Groupes : comp.lang.c++Date : 26. Sep 2024, 18:48:53
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vd46q6$93f5$3@dont-email.me>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Mozilla Thunderbird
On 9/26/2024 10:44 AM, Bonita Montero wrote:
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.
Adaptive mutexes with the right spin counts do make a difference!
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.
I just showed you one use of try_lock. This is just one out of many. try_lock is useful.