Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

<Overfiend> Joy: Hey, I'm an asshole. Assholes emit odious gas. That's what we do.


devel / comp.lang.c++ / Re: Thread-safe initialization of static objects

SubjectAuthor
* Thread-safe initialization of static objectsBonita Montero
+* Re: Thread-safe initialization of static objectsPavel
|+* Re: Thread-safe initialization of static objectsBonita Montero
||+* Re: Thread-safe initialization of static objectsPavel
|||`* Re: Thread-safe initialization of static objectsBonita Montero
||| `* Re: Thread-safe initialization of static objectsPavel
|||  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   +* Re: Thread-safe initialization of static objectsScott Lurndal
|||   |+* Re: Thread-safe initialization of static objectsRichard Damon
|||   ||`* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   || `* Re: Thread-safe initialization of static objectsRichard Damon
|||   ||  `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   ||   +* Re: Thread-safe initialization of static objectsRichard Damon
|||   ||   |`- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   ||   `* Re: Thread-safe initialization of static objectsScott Lurndal
|||   ||    `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   |`- Re: Thread-safe initialization of static objectsBonita Montero
|||   +* Re: Thread-safe initialization of static objectsPavel
|||   |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | +* Re: Thread-safe initialization of static objectsPavel
|||   | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | +* Re: Thread-safe initialization of static objectsPaavo Helde
|||   | | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | +* Re: Thread-safe initialization of static objectsPavel
|||   | | | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | +* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | | | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | +* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | | | | |+* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||+* Re: Thread-safe initialization of static objectsPaavo Helde
|||   | | | | | |||+* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||||+- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | ||||`* Re: Thread-safe initialization of static objectsPaavo Helde
|||   | | | | | |||| +* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | |||| |+- Re: Thread-safe initialization of static objectsRichard Damon
|||   | | | | | |||| |`- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | |||| `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||||  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||||   `* Re: Thread-safe initialization of static objectsPaavo Helde
|||   | | | | | ||||    +- Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||||    `- Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | |||`* Re: Thread-safe initialization of static objectsMichael S
|||   | | | | | ||| +- Re: Thread-safe initialization of static objectsScott Lurndal
|||   | | | | | ||| `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | ||`* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | | | | || `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | |`* Re: Thread-safe initialization of static objectsPavel
|||   | | | | | | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | |  `* Re: Thread-safe initialization of static objectsPavel
|||   | | | | | |   `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | |    `- Re: Thread-safe initialization of static objectsPavel
|||   | | | | | `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | `- Re: Thread-safe initialization of static objectsPavel
|||   | | | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |   +* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |   | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   |  +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   |  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |   |   +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   |   `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   `* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | |    `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |     +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |     `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |      `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |       `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |        `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |         `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |          `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |           `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |            `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |             `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |              +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |              `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |               `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                 `* Re: Thread-safe initialization of static objectsScott Lurndal
|||   | | |                  +- Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                  `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                   `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                    `* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | |                     `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                      `* Re: Thread-safe initialization of static objectsPavel
|||   | | |                       `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        +* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   +* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | +* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   | |  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | |   `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   | |    `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | |     `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   | |      `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   `* Re: Thread-safe initialization of static objectsKaz Kylheku
|||   | | |                        `* Re: Thread-safe initialization of static objectsPavel
|||   | | `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   `- Re: Thread-safe initialization of static objectsMarcel Mueller
||`- Re: Thread-safe initialization of static objectsChris M. Thomasson
|`* Re: Thread-safe initialization of static objectsChris M. Thomasson
+* Re: Thread-safe initialization of static objectsPaavo Helde
+* Re: Thread-safe initialization of static objectsChris M. Thomasson
+* Re: Thread-safe initialization of static objectsChris M. Thomasson
`* Re: Thread-safe initialization of static objectsFrederick Virchanza Gotham

Pages:123456789101112131415161718192021222324252627
Re: Thread-safe initialization of static objects

<jGHNM.23270$H8td.15049@fx10.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1508&group=comp.lang.c%2B%2B#1508

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me> <xxHNM.70742$i1yc.39429@fx15.iad>
<ue7gmv$g3o5$2@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ue7gmv$g3o5$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 16
Message-ID: <jGHNM.23270$H8td.15049@fx10.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 17 Sep 2023 14:35:59 -0400
X-Received-Bytes: 2413
 by: Richard Damon - Sun, 17 Sep 2023 18:35 UTC

On 9/17/23 2:32 PM, Bonita Montero wrote:
> Am 17.09.2023 um 20:26 schrieb Richard Damon:
>
>> You have it backwards. If the mutex object actually CAN fail, than any
>> implementation that uses them, and don'y handle the failure, is
>> incorrect.
>
> The standard should allow an implementation that fails and have
> a way to handle that; a system_error would be the most appropiate
> way.

Nope, if a system can't actually find a way to reliably do file scope
initialization, it shouldn't be able to call itself conforming.

Yes, you can use some faster but fail-prone methods first, but if they
fail then you need to fall back to (possibly) slower but reliable methods.

Re: Thread-safe initialization of static objects

<oHHNM.23271$H8td.1529@fx10.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1509&group=comp.lang.c%2B%2B#1509

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ue7f6g$frod$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 17
Message-ID: <oHHNM.23271$H8td.1529@fx10.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 17 Sep 2023 14:37:08 -0400
X-Received-Bytes: 2234
 by: Richard Damon - Sun, 17 Sep 2023 18:37 UTC

On 9/17/23 2:06 PM, Bonita Montero wrote:
> Am 17.09.2023 um 19:37 schrieb Pavel:
>
>> Bonita Montero wrote:
>>> As I've shown with my program MSVC, libstdc++ (g++) and libc++ (clang++)
>>> have per object mutexes.
>
>> No your program does not show this. ...
>
> Of course I show this. I've got a generic lambda and each thread
> gets its own instantiation of the calling operator of that lambda,
> thereby having _individual_ static objects per calling operator.
>

You haven't actually looked at HOW the code actually does what it does,
so you haven't shown anything (except your own limitations in
understanding code).

Re: Thread-safe initialization of static objects

<ue7hb6$g6eb$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1511&group=comp.lang.c%2B%2B#1511

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 11:42:45 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <ue7hb6$g6eb$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:42:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="530891"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wi4xTrb/eJoKe8T8nQYPcNeEPbx0ymcI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:c58FqvCidsGL0D4rGIS7y44AiVs=
In-Reply-To: <ue7gkn$g3o5$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:42 UTC

On 9/17/2023 11:30 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:25 schrieb Chris M. Thomasson:
>
>> Getting WAIT_FAILED means something really bad has hit the fan.
>> WAIT_ABANDONED is fine and can be handled, akin to EOWNERDEAD.
>> This is for inter-process robust sync.
>
> It's unspecified why this happens.
>
>> A futex does not need to create new kernel resources on demand.
>> They are already there.
>
> Read the Linux futex paper. The page which holds the futex is locked
> and there's a wating queue for contenders inside the kernel.
>
>

They depend on an atomic predicate in userspace. The kernel resources do
not get created on demand such that they can fail to be created, because
they are already there. The kernel only gets used when the userspace
algorihtm needs to wait, aka, a slow path...

std::uintptr_t can be used as a futex. The userspace code does not need
to create anything in the kernel. Humm... You sound like you are not all
that familiar with them. So be it.

Re: Thread-safe initialization of static objects

<ue7hc3$g7tm$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1512&group=comp.lang.c%2B%2B#1512

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 20:43:16 +0200
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <ue7hc3$g7tm$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:43:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="532406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lt+T1Z5BeLCUYZ2aznIZ+m++Fn6brERs="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:JZRsspJ0n0Fjc07UoaUa6kb1aCs=
In-Reply-To: <ue7gdm$fumm$4@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sun, 17 Sep 2023 18:43 UTC

Am 17.09.2023 um 20:27 schrieb Chris M. Thomasson:
> On 9/17/2023 11:06 AM, Bonita Montero wrote:
>> Am 17.09.2023 um 19:37 schrieb Pavel:
>>
>>> Bonita Montero wrote:
>>>> As I've shown with my program MSVC, libstdc++ (g++) and libc++
>>>> (clang++)
>>>> have per object mutexes.
>>
>>> No your program does not show this. ...
>>
>> Of course I show this. I've got a generic lambda and each thread
>> gets its own instantiation of the calling operator of that lambda,
>> thereby having _individual_ static objects per calling operator.
>>
>
> Sigh.

Here's the code again:

#include <iostream>
#include <utility>
#include <vector>
#include <thread>

using namespace std;

int main()
{ struct InitSleep
{
InitSleep()
{
this_thread::sleep_for( 1s );
}
};
constexpr unsigned N_THREADS = 100;
auto unroll = []<size_t ... Indices>( index_sequence<Indices ...>, auto
fn )
{
(fn.template operator ()<Indices>(), ...);
};
vector<jthread> threads;
threads.reserve( N_THREADS );
unroll( make_index_sequence<N_THREADS>(),
[&]<size_t T>()
{
threads.emplace_back( []( auto )
{
static InitSleep is;
}, integral_constant<size_t, T>() );
} );
}

The calling operator of the theads's function object is generic
and instantited once per T. So the static is object is individual
per each instantiation of the calling operator. The above code
takes about one second with MSVC, g++ (libstdc++) and clan++
(libc++), so there's an individual mutex per calling operator
of the above lambda.
So if you handle it that way creating synchronization and the
synchronization may fail. The standard shoud support appropriate
error handling if initialization is done that fine grained like
with the mentioned implementations.

Re: Thread-safe initialization of static objects

<ue7hcp$g6eb$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1513&group=comp.lang.c%2B%2B#1513

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 11:43:36 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ue7hcp$g6eb$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me> <xxHNM.70742$i1yc.39429@fx15.iad>
<ue7gmv$g3o5$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:43:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="530891"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19v2+av3IwgkBHsQKlJomqfid7s3gVaXcg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:8rGlgI8El521vJbn1Hb1Ak325j8=
In-Reply-To: <ue7gmv$g3o5$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:43 UTC

On 9/17/2023 11:32 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:26 schrieb Richard Damon:
>
>> You have it backwards. If the mutex object actually CAN fail, than any
>> implementation that uses them, and don'y handle the failure, is
>> incorrect.
>
> The standard should allow an implementation that fails and have
> a way to handle that; a system_error would be the most appropiate
> way.

Sigh.

Re: Thread-safe initialization of static objects

<ue7hdn$g7tm$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1514&group=comp.lang.c%2B%2B#1514

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 20:44:08 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <ue7hdn$g7tm$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <ue7hb6$g6eb$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:44:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="532406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/idtqi+Ihlnu/UR3Ra9m2qw1LoKtX7mV4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hvp/ZeCmEC3aWnt4CkZhw5EZdAk=
Content-Language: de-DE
In-Reply-To: <ue7hb6$g6eb$1@dont-email.me>
 by: Bonita Montero - Sun, 17 Sep 2023 18:44 UTC

Am 17.09.2023 um 20:42 schrieb Chris M. Thomasson:

> They depend on an atomic predicate in userspace. ..

This is not really userspace if the page accesses are trapped to have
a faster way inside the kernel.

Re: Thread-safe initialization of static objects

<ue7hip$g7tm$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1515&group=comp.lang.c%2B%2B#1515

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 20:46:51 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ue7hip$g7tm$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <0M4LM.170545$uEkc.43152@fx35.iad>
<udk0hm$h1e9$3@dont-email.me> <udl0ti$lp5v$4@dont-email.me>
<udn883$135tl$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<DjENM.51886$8XGa.26896@fx17.iad> <ue77ul$eiv3$1@dont-email.me>
<8SGNM.4844$3lL1.4797@fx47.iad> <ue7f3i$frod$1@dont-email.me>
<xxHNM.70742$i1yc.39429@fx15.iad> <ue7gmv$g3o5$2@dont-email.me>
<jGHNM.23270$H8td.15049@fx10.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:46:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="532406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19l8b+xfV/n490+J9EqGTaNj6hU5cQyTi4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LS2K9jq6SeYGwGtCM797n99sPGQ=
Content-Language: de-DE
In-Reply-To: <jGHNM.23270$H8td.15049@fx10.iad>
 by: Bonita Montero - Sun, 17 Sep 2023 18:46 UTC

Am 17.09.2023 um 20:35 schrieb Richard Damon:

> Nope, if a system can't actually find a way to reliably do file scope
> initialization, it shouldn't be able to call itself conforming.

global static objects are a different issue. They're not created with
contention since they're created before main. I was concerned about
static local objects. And the way I suggested would provide a bit
cleaner initialization.

Re: Thread-safe initialization of static objects

<ue7hmh$g6eb$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1516&group=comp.lang.c%2B%2B#1516

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 11:48:48 -0700
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <ue7hmh$g6eb$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 17 Sep 2023 18:48:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="530891"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/CLPzOxKaJC5p4plYoswZ1KlEHDm12J04="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:emNP1YTGDXu27hZTZAexkSwhYzM=
In-Reply-To: <ue7hc3$g7tm$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:48 UTC

On 9/17/2023 11:43 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:27 schrieb Chris M. Thomasson:
>> On 9/17/2023 11:06 AM, Bonita Montero wrote:
>>> Am 17.09.2023 um 19:37 schrieb Pavel:
>>>
>>>> Bonita Montero wrote:
>>>>> As I've shown with my program MSVC, libstdc++ (g++) and libc++
>>>>> (clang++)
>>>>> have per object mutexes.
>>>
>>>> No your program does not show this. ...
>>>
>>> Of course I show this. I've got a generic lambda and each thread
>>> gets its own instantiation of the calling operator of that lambda,
>>> thereby having _individual_ static objects per calling operator.
>>>
>>
>> Sigh.
>
> Here's the code again:
>
> #include <iostream>
> #include <utility>
> #include <vector>
> #include <thread>
>
> using namespace std;
>
> int main()
> {
>     struct InitSleep
>     {
>         InitSleep()
>         {
>             this_thread::sleep_for( 1s );
>         }
>     };
>     constexpr unsigned N_THREADS = 100;
>     auto unroll = []<size_t ... Indices>( index_sequence<Indices ...>,
> auto fn )
>     {
>         (fn.template operator ()<Indices>(), ...);
>     };
>     vector<jthread> threads;
>     threads.reserve( N_THREADS );
>     unroll( make_index_sequence<N_THREADS>(),
>         [&]<size_t T>()
>         {
>             threads.emplace_back( []( auto )
>                 {
>                     static InitSleep is;
>                 }, integral_constant<size_t, T>() );
>         } );
> }
>
> The calling operator of the theads's function object is generic
> and instantited once per T. So the static is object is individual
> per each instantiation of the calling operator. The above code
> takes about one second with MSVC, g++ (libstdc++) and clan++
> (libc++), so there's an individual mutex per calling operator
> of the above lambda.

Sigh.

> So if you handle it that way creating synchronization and the
> synchronization may fail. The standard shoud support appropriate
> error handling if initialization is done that fine grained like
> with the mentioned implementations.
>
>
>
>

Re: Thread-safe initialization of static objects

<20230917112958.807@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1517&group=comp.lang.c%2B%2B#1517

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 18:49:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <20230917112958.807@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me>
Injection-Date: Sun, 17 Sep 2023 18:49:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5639c8ba62cd0d10bf2c7b8f7812f3b5";
logging-data="534228"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/U/PRtraGtfFAx8xIN1QZJl6kmq0TgDqc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:ReL7Ej4cHwRtNZrzU1ORhiRback=
 by: Kaz Kylheku - Sun, 17 Sep 2023 18:49 UTC

On 2023-09-17, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 17.09.2023 um 19:40 schrieb Richard Damon:
>
>> By the Standard, static initialization isn't allowed to have a
>> "syncronization issue", ...
>
> If you implement it that way like MSVC, libc++ and libstdc++ with
> a mutex per object synchronization can fail. And the standard should
> define what happens then.

When mutexes fail, it is due to bugs in the application. In that case,
if that happens at global init time, the program can just abort.

In POSIX, the only legitimate external error in a mutex operation
occurs when a mutex is process shared, and another process has locked
it and then terminated. This situation is indicated to the caller of
pthread_mutex_lock which is essentially tasked with cleaning up the
situation somehow. Even that is a programming error though: a bug in
the multi-process application that its components are failing while
holding a shared mutex. It is nto a genuine external condition like
"file not found", "permission denied" or "network down" or "I/O error".

All the other error situations in a mutex are local error checks for
debugging. Those situations should not happen, among them being:

- unlocking a mutex which is not owned by the calling thread.

- deadlock

- recursively locking a mutex that is not recursive

- anything else, like using a corrupt mutex.

A correctly used mutex in a correct program free of deadlocks
does not fail.

If a debugging mutex is used for thread-safe once-only static inits, it
would be acceptable to abort if that mutex indicates a problem.

Turning that into an exception would be fine, though there likely
isn't any useful way to recover from it. Leaving it unhandled would
be the best.

Most attempts in C++ code to deal with a program logic error via
exception handling only succeed in making it harder to debug,
because unwinding destroys vital information about the problem.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Thread-safe initialization of static objects

<ue7hnl$g7tm$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1518&group=comp.lang.c%2B%2B#1518

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 20:49:26 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ue7hnl$g7tm$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <oHHNM.23271$H8td.1529@fx10.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:49:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="532406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+0/F6FVZvWD6W43Eyh6e0xKGE1RxX3Co="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:SFb4LybchudMUsVQ07zXJKcpHIE=
In-Reply-To: <oHHNM.23271$H8td.1529@fx10.iad>
Content-Language: de-DE
 by: Bonita Montero - Sun, 17 Sep 2023 18:49 UTC

Am 17.09.2023 um 20:37 schrieb Richard Damon:

> You haven't actually looked at HOW the code actually does what it does,
> so you haven't shown anything (except your own limitations in
> understanding code).

I don't need to check that. I've proven that each static local
object has its own initialization and not a shared mutex because
the code runs exactly one second. So if you have an indivivual
mutex per static local object this synchronization may fail.
A pre-allocated global mutex for all static local initialization
may not fail, but the standard should honour platforms where
this actually can happen.

Re: Thread-safe initialization of static objects

<ue7hps$g6eb$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1519&group=comp.lang.c%2B%2B#1519

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 11:50:35 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ue7hps$g6eb$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <ue7hb6$g6eb$1@dont-email.me>
<ue7hdn$g7tm$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:50:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="530891"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AE3gPpEE8xHJHzred+SFqDTGbbMf3Qq0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:jrTnl9rEJFT0Lee97BO+ah9CBv8=
Content-Language: en-US
In-Reply-To: <ue7hdn$g7tm$2@dont-email.me>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:50 UTC

On 9/17/2023 11:44 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:42 schrieb Chris M. Thomasson:
>
>> They depend on an atomic predicate in userspace. ..
>
> This is not really userspace if the page accesses are trapped to have
> a faster way inside the kernel.
>

Huh? Futexes are designed to allow userspace to use them efficiently.

Re: Thread-safe initialization of static objects

<ue7hrt$gach$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1520&group=comp.lang.c%2B%2B#1520

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 11:51:40 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ue7hrt$gach$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <ue7hb6$g6eb$1@dont-email.me>
<ue7hdn$g7tm$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:51:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="534929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Ct2WMc9nWI6TiRe3pikwcZ2Qxp1soSZ0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:GG7m2LrLkSbE5/Twqacqje3d+Cs=
Content-Language: en-US
In-Reply-To: <ue7hdn$g7tm$2@dont-email.me>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:51 UTC

On 9/17/2023 11:44 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:42 schrieb Chris M. Thomasson:
>
>> They depend on an atomic predicate in userspace. ..
>
> This is not really userspace if the page accesses are trapped to have
> a faster way inside the kernel.
>

What is the difference between a fast-path and a slow-path wrt
synchronization algorithms?

Re: Thread-safe initialization of static objects

<ue7hsb$g7tm$5@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1521&group=comp.lang.c%2B%2B#1521

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 20:51:56 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ue7hsb$g7tm$5@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me> <20230917112958.807@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:51:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="532406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hVOT+CLOsxm7vFtSYRyTtpV93gOUzClE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:3OCCwDP4UPCsuxt6MTiP+Jh12Zc=
Content-Language: de-DE
In-Reply-To: <20230917112958.807@kylheku.com>
 by: Bonita Montero - Sun, 17 Sep 2023 18:51 UTC

Am 17.09.2023 um 20:49 schrieb Kaz Kylheku:

> When mutexes fail, it is due to bugs in the application. In that case,
> if that happens at global init time, the program can just abort.

C++ mutexes always have a delayed initialitation since the constructor
is noexcept. So the semaphore behind the mutex which backs contention
is created on synchonzation, which may fail.

> In POSIX, ..

It doesn't matter what a specific operating system says about that,
the standard should honour a failure in this case, even more if you
have deferred initialization with C++ mutexes.

Rest unread.

Re: Thread-safe initialization of static objects

<ue7hto$gach$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1522&group=comp.lang.c%2B%2B#1522

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 11:52:39 -0700
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <ue7hto$gach$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <oHHNM.23271$H8td.1529@fx10.iad>
<ue7hnl$g7tm$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:52:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="534929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cqZ/Y3R/2VGZzQ76qsA/B5CydZLs9vcs="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:LOW/FOfP+PlN8QbB6NEZo374Gnk=
Content-Language: en-US
In-Reply-To: <ue7hnl$g7tm$4@dont-email.me>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:52 UTC

On 9/17/2023 11:49 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:37 schrieb Richard Damon:
>
>> You haven't actually looked at HOW the code actually does what it
>> does, so you haven't shown anything (except your own limitations in
>> understanding code).
>
> I don't need to check that. I've proven that each static local
> object has its own initialization and not a shared mutex because
> the code runs exactly one second.

Huh? wow.

> So if you have an indivivual
> mutex per static local object this synchronization may fail.

WOW!

> A pre-allocated global mutex for all static local initialization
> may not fail, but the standard should honour platforms where
> this actually can happen.
>

Cough...

Re: Thread-safe initialization of static objects

<ue7htp$g7tm$6@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1523&group=comp.lang.c%2B%2B#1523

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 20:52:43 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ue7htp$g7tm$6@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <ue7hb6$g6eb$1@dont-email.me>
<ue7hdn$g7tm$2@dont-email.me> <ue7hps$g6eb$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:52:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="532406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XsD4RnToWWgcDjtxRmSiY3aWAPFQoQ48="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:D/yOQGif0OPNXDTK8ZExUJHn+p0=
Content-Language: de-DE
In-Reply-To: <ue7hps$g6eb$4@dont-email.me>
 by: Bonita Montero - Sun, 17 Sep 2023 18:52 UTC

Am 17.09.2023 um 20:50 schrieb Chris M. Thomasson:
> On 9/17/2023 11:44 AM, Bonita Montero wrote:
>> Am 17.09.2023 um 20:42 schrieb Chris M. Thomasson:
>>
>>> They depend on an atomic predicate in userspace. ..
>>
>> This is not really userspace if the page accesses are trapped to have
>> a faster way inside the kernel.
>>
>
> Huh? Futexes are designed to allow userspace to use them efficiently.

You don't understand futexes. If you have contention
there's still a kernel-transition through a MMU trap.

Re: Thread-safe initialization of static objects

<ue7hvn$gach$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1524&group=comp.lang.c%2B%2B#1524

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 11:53:42 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <ue7hvn$gach$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me> <20230917112958.807@kylheku.com>
<ue7hsb$g7tm$5@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 17 Sep 2023 18:53:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="534929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188036/kfC4tpOnX5l+HPKuWE6GHpSE6w8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:b76WwiYp1OXT1ff64W0KZRZNFKA=
Content-Language: en-US
In-Reply-To: <ue7hsb$g7tm$5@dont-email.me>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:53 UTC

On 9/17/2023 11:51 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:49 schrieb Kaz Kylheku:
>
>> When mutexes fail, it is due to bugs in the application.  In that case,
>> if that happens at global init time, the program can just abort.
>
> C++ mutexes always have a delayed initialitation since the constructor
> is noexcept. So the semaphore behind the mutex which backs contention
> is created on synchonzation, which may fail.

Wtf are you rambling on about!

>
>> In POSIX, ..
>
> It doesn't matter what a specific operating system says about that,
> the standard should honour a failure in this case, even more if you
> have deferred initialization with C++ mutexes.
>
> Rest unread.
>

Re: Thread-safe initialization of static objects

<ue7ib9$gcfr$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1525&group=comp.lang.c%2B%2B#1525

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 20:59:53 +0200
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <ue7ib9$gcfr$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <0M4LM.170545$uEkc.43152@fx35.iad>
<udk0hm$h1e9$3@dont-email.me> <udl0ti$lp5v$4@dont-email.me>
<udn883$135tl$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<DjENM.51886$8XGa.26896@fx17.iad> <ue77ul$eiv3$1@dont-email.me>
<8SGNM.4844$3lL1.4797@fx47.iad> <ue7f3i$frod$1@dont-email.me>
<20230917112958.807@kylheku.com> <ue7hsb$g7tm$5@dont-email.me>
<ue7hvn$gach$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 17 Sep 2023 18:59:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="537083"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19y+YVYxjzynEowkUYsaX6t9gyhZxh9uKM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Vi1aKCHZjwIczYir7+asQDEt3ZM=
In-Reply-To: <ue7hvn$gach$3@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sun, 17 Sep 2023 18:59 UTC

Am 17.09.2023 um 20:53 schrieb Chris M. Thomasson:
> On 9/17/2023 11:51 AM, Bonita Montero wrote:
>> Am 17.09.2023 um 20:49 schrieb Kaz Kylheku:
>>
>>> When mutexes fail, it is due to bugs in the application.  In that case,
>>> if that happens at global init time, the program can just abort.
>>
>> C++ mutexes always have a delayed initialitation since the constructor
>> is noexcept. So the semaphore behind the mutex which backs contention
>> is created on synchonzation, which may fail.
>
> Wtf are you rambling on about!

You alleged me to not understand futexes and you don't understand
that yourself. Ask yourself how a mutex handles contention so that
a thread sleeps while another is processing.

Re: Thread-safe initialization of static objects

<ue7idv$gach$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1526&group=comp.lang.c%2B%2B#1526

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 12:01:18 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <ue7idv$gach$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <ue7hb6$g6eb$1@dont-email.me>
<ue7hdn$g7tm$2@dont-email.me> <ue7hps$g6eb$4@dont-email.me>
<ue7htp$g7tm$6@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 19:01:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="534929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0njo8j3gkwtQYNlzgF8SbBAZMxwA9c44="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:2FcZoF1UCQ+80Z5As8FMwM6Ztw4=
Content-Language: en-US
In-Reply-To: <ue7htp$g7tm$6@dont-email.me>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 19:01 UTC

On 9/17/2023 11:52 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:50 schrieb Chris M. Thomasson:
>> On 9/17/2023 11:44 AM, Bonita Montero wrote:
>>> Am 17.09.2023 um 20:42 schrieb Chris M. Thomasson:
>>>
>>>> They depend on an atomic predicate in userspace. ..
>>>
>>> This is not really userspace if the page accesses are trapped to have
>>> a faster way inside the kernel.
>>>
>>
>> Huh? Futexes are designed to allow userspace to use them efficiently.
>
> You don't understand futexes.

Oh please! wow.

> If you have contention
> there's still a kernel-transition through a MMU trap.

A slow-path in a synchronization algorithm can cause it to choose to
wait in the kernel, that is fine. If nothing waited in the kernel when a
slow-path is encountered, then, well, that would be spin-waits, not
exactly ideal for userspace. Think about it. An adaptive mutex will spin
wait a couple of times _before_ it has to wait in the kernel. It uses
this spin waiting to try to avoid calling into the kernel.

Did you know that a mutex does not need to create any kernel resources
at all? It can be a single word, that uses futex when it needs to wait.

No. Bonita. You need to study up.

Re: Thread-safe initialization of static objects

<ue7j3g$ggh4$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1527&group=comp.lang.c%2B%2B#1527

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 21:12:49 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ue7j3g$ggh4$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <0M4LM.170545$uEkc.43152@fx35.iad>
<udk0hm$h1e9$3@dont-email.me> <udl0ti$lp5v$4@dont-email.me>
<udn883$135tl$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<ue4t6i$3um57$1@dont-email.me> <ue5sp2$7ms9$1@dont-email.me>
<ue7gb8$fumm$3@dont-email.me> <ue7gkn$g3o5$1@dont-email.me>
<ue7hb6$g6eb$1@dont-email.me> <ue7hdn$g7tm$2@dont-email.me>
<ue7hps$g6eb$4@dont-email.me> <ue7htp$g7tm$6@dont-email.me>
<ue7idv$gach$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 19:12:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="541220"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ohNjrt/TocsjLhw3dXGIciLJBwWYUZ2M="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:MWGDWE6htga4+ZFeNEnzeTwGgp8=
Content-Language: de-DE
In-Reply-To: <ue7idv$gach$4@dont-email.me>
 by: Bonita Montero - Sun, 17 Sep 2023 19:12 UTC

Am 17.09.2023 um 21:01 schrieb Chris M. Thomasson:

> A slow-path in a synchronization algorithm can cause it to choose to
> wait in the kernel, ...

Futexes are a substitute for a semaphore, which in turn is a part of
a mutex. There must be a way to get a thread sleeping when there's
contention. So there must be kernel-support of a futex.
If you say that everything on that futex happens in userspace this
does just mean that there's no explicit kernel call from userspace,
but the kernel-transition is done through a MMU-trap, wich is usually
faster on most CPUs than a explicit kernel call.

> No. Bonita. You need to study up.

I've read the paper, you didn't understand or you didn't read it.

Re: Thread-safe initialization of static objects

<20230917121015.206@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1528&group=comp.lang.c%2B%2B#1528

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 19:20:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20230917121015.206@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me>
Injection-Date: Sun, 17 Sep 2023 19:20:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5639c8ba62cd0d10bf2c7b8f7812f3b5";
logging-data="545459"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Wqpnb0HWvNPuq8TlMlxOFHoQd1QMseTc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:vt+Ts+9+eEV1C693bjO9cdnZxm0=
 by: Kaz Kylheku - Sun, 17 Sep 2023 19:20 UTC

On 2023-09-17, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 17.09.2023 um 20:25 schrieb Chris M. Thomasson:
>
>> Getting WAIT_FAILED means something really bad has hit the fan.
>> WAIT_ABANDONED is fine and can be handled, akin to EOWNERDEAD.
>> This is for inter-process robust sync.
>
> It's unspecified why this happens.
>
>> A futex does not need to create new kernel resources on demand.
>> They are already there.
>
> Read the Linux futex paper. The page which holds the futex is locked
> and there's a wating queue for contenders inside the kernel.

Locking a page is just a state change, not a resource allocation.

Waiting on wait queues doesn't require external resources; Linux wait
queue nodes are allocated and initialized on the stack. The enqueueing
and dequeueing is just pointer operations.

Wait queues themselves have to be allocated somewhere. The Linux futex
subsystem pre-allocated a big hash table containing queues. A futex
is hashed and then arbitrarily mapped to a queue which already exists.
The operation does not fail; there is no error checking or handling in
that code path at all. The futex hash allows unrelated futexes to map to
the same wait queue. That means that when a futex is woken up, tasks
waiting for a different futex may be woken as a side effect.

A page which holds a futex might be initially not present and have
to be swapped in. That's a resource allocation that can fail due to OOM.
However, that threat exists for any not-present page in an overcommitted
VM system; it's not a futex problem. You can malloc a block of memory,
get a non-null pointer, only to have it fail on access later.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Thread-safe initialization of static objects

<20230917122041.465@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1529&group=comp.lang.c%2B%2B#1529

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 19:22:12 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <20230917122041.465@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me> <20230917112958.807@kylheku.com>
<ue7hsb$g7tm$5@dont-email.me>
Injection-Date: Sun, 17 Sep 2023 19:22:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5639c8ba62cd0d10bf2c7b8f7812f3b5";
logging-data="545459"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Jk/xUGBt2jEbqTDcNY2yYTT9K8SW5MQM="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:saw28bYVCp/WeHjFxw0GiMDtzg4=
 by: Kaz Kylheku - Sun, 17 Sep 2023 19:22 UTC

On 2023-09-17, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 17.09.2023 um 20:49 schrieb Kaz Kylheku:
>
>> When mutexes fail, it is due to bugs in the application. In that case,
>> if that happens at global init time, the program can just abort.
>
> C++ mutexes always have a delayed initialitation since the constructor
> is noexcept. So the semaphore behind the mutex which backs contention
> is created on synchonzation, which may fail.
>
>> In POSIX, ..
>
> It doesn't matter what a specific operating system says about that,

s/operating system/international standard for operating system family/

> Rest unread.

Aha; I think this is your approach to documentation also.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Thread-safe initialization of static objects

<ue7k2n$gmqv$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1530&group=comp.lang.c%2B%2B#1530

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 21:29:28 +0200
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <ue7k2n$gmqv$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <20230917121015.206@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 19:29:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="547679"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ryh19M49tGwTJDI1BpnQnW4tpPN+CtVM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:W5V5NuSKJKiKyMXxoSS+urnd9LA=
In-Reply-To: <20230917121015.206@kylheku.com>
Content-Language: de-DE
 by: Bonita Montero - Sun, 17 Sep 2023 19:29 UTC

Am 17.09.2023 um 21:20 schrieb Kaz Kylheku:

> Locking a page is just a state change, not a resource allocation.

That's a completely different discussion. The standard should not
be based on individual implementations, but should allow for the
possibility that the failure of synchronization or the synchroni-
zation itself fails. The standard also provides for this with a
std::mutex, why not for the initialization of statically local
objects ?

Rest unread.

Re: Thread-safe initialization of static objects

<20230917123203.524@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1531&group=comp.lang.c%2B%2B#1531

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 19:36:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <20230917123203.524@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <20230917121015.206@kylheku.com>
<ue7k2n$gmqv$1@dont-email.me>
Injection-Date: Sun, 17 Sep 2023 19:36:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5639c8ba62cd0d10bf2c7b8f7812f3b5";
logging-data="545459"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/x895GYrKrbFSSWN4dFCRHWVwYAfgqGKM="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:CyknNBwiLe6tmb+xl5Fwhit6eJw=
 by: Kaz Kylheku - Sun, 17 Sep 2023 19:36 UTC

On 2023-09-17, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 17.09.2023 um 21:20 schrieb Kaz Kylheku:
>
>> Locking a page is just a state change, not a resource allocation.
>
> That's a completely different discussion. The standard should not
> be based on individual implementations, but should allow for the
> possibility that the failure of synchronization or the synchroni-
> zation itself fails.

No it shouldn't. Synchronization that fails for reasons other than
a bug in the program (deadlock, unlocking un-owned mutex, recursively
acquiring non-recursive mutex, ...) is a wrongheaded idea, that should
not and need not be contemplated by any language or library standard
anywhere, ever.

Futexes are carefully designed not to require resource allocation
in futex_wait, in light of the above common understanding.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Thread-safe initialization of static objects

<YDINM.23273$H8td.19873@fx10.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1532&group=comp.lang.c%2B%2B#1532

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ue7hc3$g7tm$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 76
Message-ID: <YDINM.23273$H8td.19873@fx10.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 17 Sep 2023 15:41:44 -0400
X-Received-Bytes: 4259
 by: Richard Damon - Sun, 17 Sep 2023 19:41 UTC

On 9/17/23 2:43 PM, Bonita Montero wrote:
> Am 17.09.2023 um 20:27 schrieb Chris M. Thomasson:
>> On 9/17/2023 11:06 AM, Bonita Montero wrote:
>>> Am 17.09.2023 um 19:37 schrieb Pavel:
>>>
>>>> Bonita Montero wrote:
>>>>> As I've shown with my program MSVC, libstdc++ (g++) and libc++
>>>>> (clang++)
>>>>> have per object mutexes.
>>>
>>>> No your program does not show this. ...
>>>
>>> Of course I show this. I've got a generic lambda and each thread
>>> gets its own instantiation of the calling operator of that lambda,
>>> thereby having _individual_ static objects per calling operator.
>>>
>>
>> Sigh.
>
> Here's the code again:
>
> #include <iostream>
> #include <utility>
> #include <vector>
> #include <thread>
>
> using namespace std;
>
> int main()
> {
>     struct InitSleep
>     {
>         InitSleep()
>         {
>             this_thread::sleep_for( 1s );
>         }
>     };
>     constexpr unsigned N_THREADS = 100;
>     auto unroll = []<size_t ... Indices>( index_sequence<Indices ...>,
> auto fn )
>     {
>         (fn.template operator ()<Indices>(), ...);
>     };
>     vector<jthread> threads;
>     threads.reserve( N_THREADS );
>     unroll( make_index_sequence<N_THREADS>(),
>         [&]<size_t T>()
>         {
>             threads.emplace_back( []( auto )
>                 {
>                     static InitSleep is;
>                 }, integral_constant<size_t, T>() );
>         } );
> }
>
> The calling operator of the theads's function object is generic
> and instantited once per T. So the static is object is individual
> per each instantiation of the calling operator. The above code
> takes about one second with MSVC, g++ (libstdc++) and clan++
> (libc++), so there's an individual mutex per calling operator
> of the above lambda.
> So if you handle it that way creating synchronization and the
> synchronization may fail. The standard shoud support appropriate
> error handling if initialization is done that fine grained like
> with the mentioned implementations.
>
>

Which just means that there is a path that, in this case, allows
parallel execution. Note, there are ways to handle this synchronization
that doesn't need holding a mutex per instance for the full time of the
constructor running.

Until you look at the code ACTUALLY GENERATED, you don't know how they
are doing it.

Re: Thread-safe initialization of static objects

<kFINM.23274$H8td.18289@fx10.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1533&group=comp.lang.c%2B%2B#1533

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <oHHNM.23271$H8td.1529@fx10.iad>
<ue7hnl$g7tm$4@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ue7hnl$g7tm$4@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 22
Message-ID: <kFINM.23274$H8td.18289@fx10.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 17 Sep 2023 15:43:12 -0400
X-Received-Bytes: 2633
 by: Richard Damon - Sun, 17 Sep 2023 19:43 UTC

On 9/17/23 2:49 PM, Bonita Montero wrote:
> Am 17.09.2023 um 20:37 schrieb Richard Damon:
>
>> You haven't actually looked at HOW the code actually does what it
>> does, so you haven't shown anything (except your own limitations in
>> understanding code).
>
> I don't need to check that. I've proven that each static local
> object has its own initialization and not a shared mutex because
> the code runs exactly one second. So if you have an indivivual
> mutex per static local object this synchronization may fail.
> A pre-allocated global mutex for all static local initialization
> may not fail, but the standard should honour platforms where
> this actually can happen.
>

Nope, you shown that it can't be a single mutex held for the entire time
of the constructor.

So, you have defeated a Strawman, not proved your point.

Your logic is as bad as Olcott.


devel / comp.lang.c++ / Re: Thread-safe initialization of static objects

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor