Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Chemistry is applied theology. -- Augustus Stanley Owsley III


devel / comp.lang.c++ / 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

<uesbeo$20ej3$1@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 18:11:05 +0200
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <uesbeo$20ej3$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me>
<aa307383-8415-4e39-9cca-18a0f57bf6f4n@googlegroups.com>
<uep6ss$1b36d$2@dont-email.me> <YAVPM.165857$Hih7.40004@fx11.iad>
<uep94g$1bect$2@dont-email.me> <cd5QM.124661$1B%c.70710@fx09.iad>
<uereqt$1qg8s$2@dont-email.me> <0ZdQM.67168$3vM.59997@fx37.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 25 Sep 2023 16:11:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e2ba2e234a6dcf9f0afcd3d90854525d";
logging-data="2112099"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9Yw+pVT1JpK34CXGPBA7YX3MQjZ70WiY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ElWzh//od4PfY549kUiObHMhZ54=
In-Reply-To: <0ZdQM.67168$3vM.59997@fx37.iad>
Content-Language: de-DE
 by: Bonita Montero - Mon, 25 Sep 2023 16:11 UTC

Am 25.09.2023 um 13:15 schrieb Richard Damon:

> You argument is basically, the Standard needs to allow for BAD
> implementation to exist.

And implementation that throws in this situation isn't bad for me.

Re: Thread-safe initialization of static objects

<uesc36$20j2u$1@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 18:21:59 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <uesc36$20j2u$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <VnsPM.122464$Hih7.52058@fx11.iad>
<uelqeq$lo9j$4@dont-email.me> <XbJPM.157838$Hih7.40116@fx11.iad>
<ueo5ps$163k0$1@dont-email.me> <Y3_PM.16749$E_d1.14707@fx04.iad>
<ueqfec$1i6un$1@dont-email.me> <40iQM.146456$bmw6.71801@fx10.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 25 Sep 2023 16:21:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e2ba2e234a6dcf9f0afcd3d90854525d";
logging-data="2116702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nsqfx6MAQIubC1Ujv3TtJFPEkX74bY1k="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Hfn8OD03OwI6RgB8dgJ2UeF3a10=
In-Reply-To: <40iQM.146456$bmw6.71801@fx10.iad>
Content-Language: de-DE
 by: Bonita Montero - Mon, 25 Sep 2023 16:21 UTC

Am 25.09.2023 um 17:51 schrieb Scott Lurndal:
> Bonita Montero <Bonita.Montero@gmail.com> writes:

>> lock() and unlock() might throw system_error.

> lock() and unlock() cannot throw any error.

https://en.cppreference.com/w/cpp/thread/mutex/lock

"Throws std::system_error when errors occur, including errors
from the underlying operating system that would prevent lock
from meeting its specifications. The mutex is not locked in
the case of any exception being thrown."

https://en.cppreference.com/w/cpp/thread/mutex/unlock

"Throws nothing"

You're right only in the latter case.

Re: Thread-safe initialization of static objects

<297dc716-d4df-441e-a711-fe1ebe760ad5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:3881:b0:773:a12d:a511 with SMTP id qp1-20020a05620a388100b00773a12da511mr57857qkn.1.1695662124880;
Mon, 25 Sep 2023 10:15:24 -0700 (PDT)
X-Received: by 2002:a05:6870:b623:b0:1dd:39ce:e258 with SMTP id
cm35-20020a056870b62300b001dd39cee258mr1227129oab.4.1695662124590; Mon, 25
Sep 2023 10:15:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Mon, 25 Sep 2023 10:15:24 -0700 (PDT)
In-Reply-To: <uepvs7$1ff81$3@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:b026:a747:6967:3faa;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:b026:a747:6967:3faa
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me> <37dbe3b6-ead0-487b-884c-197124888eben@googlegroups.com>
<uepvs7$1ff81$3@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <297dc716-d4df-441e-a711-fe1ebe760ad5n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Mon, 25 Sep 2023 17:15:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3305
 by: Michael S - Mon, 25 Sep 2023 17:15 UTC

On Sunday, September 24, 2023 at 9:41:29 PM UTC+3, Chris M. Thomasson wrote:
> On 9/24/2023 2:50 AM, Michael S wrote:
> > On Sunday, September 24, 2023 at 11:09:31 AM UTC+3, Bonita Montero wrote:
> >> Am 24.09.2023 um 05:05 schrieb Chris M. Thomasson:
> >>
> >>> Why do you think that static initialization must use a std::mutex
> >>> anyway? ...
> >>
> >> Call it std::mutex or whatever. It is mandated that contenders
> >> are sleeping - that's not possible without sth. else than a mutex.
> >
> > Few dozens posts above I demonstrated an implementation
> > for pre-Vista Windows where contenders are sleeping just fine and
> > waking just fine and initialization of different objects proceeds
> > simultaneously just fine. And it does not use mutex for that.
> > It uses SleepEx() for wait and QueueUserApc() for wakeup.
>
> Why? APC's open up a big can of worms.
>

Because for pre-Vista I can't think about better solution.
https://groups.google.com/g/comp.lang.c++/c/bTiLC2zWR4M/m/XG1aWCEDAAAJ
And frankly I see no worms.

>
> > It uses one global mutex (in form of critical section) for a short
> > while for metadata updates, but that's done for simplicity and
> > practicality rather than out of necessity. I am pretty sure that
> > with enough effort I can device a variant that achieves the same
> > with CaS.

Re: Thread-safe initialization of static objects

<3ae49bbf-2fb6-47c1-83a6-402cf9656737n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:ac8:7c43:0:b0:417:afb8:ee35 with SMTP id o3-20020ac87c43000000b00417afb8ee35mr62193qtv.11.1695662454974;
Mon, 25 Sep 2023 10:20:54 -0700 (PDT)
X-Received: by 2002:a05:6871:6aa9:b0:1d6:689b:fe59 with SMTP id
zf41-20020a0568716aa900b001d6689bfe59mr3029686oab.10.1695662454719; Mon, 25
Sep 2023 10:20:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!2.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Mon, 25 Sep 2023 10:20:54 -0700 (PDT)
In-Reply-To: <ueq0bm$1fihu$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:b026:a747:6967:3faa;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:b026:a747:6967:3faa
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me> <37dbe3b6-ead0-487b-884c-197124888eben@googlegroups.com>
<uepvs7$1ff81$3@dont-email.me> <ueq0bm$1fihu$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3ae49bbf-2fb6-47c1-83a6-402cf9656737n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Mon, 25 Sep 2023 17:20:54 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Michael S - Mon, 25 Sep 2023 17:20 UTC

On Sunday, September 24, 2023 at 9:49:44 PM UTC+3, Chris M. Thomasson wrote:
> On 9/24/2023 11:41 AM, Chris M. Thomasson wrote:
> > On 9/24/2023 2:50 AM, Michael S wrote:
> >> On Sunday, September 24, 2023 at 11:09:31 AM UTC+3, Bonita Montero wrote:
> >>> Am 24.09.2023 um 05:05 schrieb Chris M. Thomasson:
> >>>
> >>>> Why do you think that static initialization must use a std::mutex
> >>>> anyway? ...
> >>>
> >>> Call it std::mutex or whatever. It is mandated that contenders
> >>> are sleeping - that's not possible without sth. else than a mutex.
> >>
> >> Few dozens posts above I demonstrated an implementation
> >> for pre-Vista Windows where contenders are sleeping just fine and
> >> waking just fine and initialization of different objects proceeds
> >> simultaneously just fine. And it does not use mutex for that.
> >> It uses SleepEx() for wait and QueueUserApc() for wakeup.
> >
> > Why? APC's open up a big can of worms.
> Oh shit. I am starting to remember some nightmare code I had to debug
> many moon ago that used async cancellation in POSIX threads.
> >
> >

But Windows User APC, at least pre Win11, is async only on issue
side. On reception side it is fully synchronous and easy to reason about.
At least it is easy as long as you don't try to enter alertable wait
within APC routine, which I don't do. In fact, my APC routine is Nop.

> >> It uses one global mutex (in form of critical section) for a short
> >> while for metadata updates, but that's done for simplicity and
> >> practicality rather than out of necessity. I am pretty sure that
> >> with enough effort I can device a variant that achieves the same
> >> with CaS.
> >
> >

Re: Thread-safe initialization of static objects

<uesh3d$21hbl$1@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 10:47:25 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uesh3d$21hbl$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me>
<aa307383-8415-4e39-9cca-18a0f57bf6f4n@googlegroups.com>
<uep6ss$1b36d$2@dont-email.me> <YAVPM.165857$Hih7.40004@fx11.iad>
<uep94g$1bect$2@dont-email.me> <cd5QM.124661$1B%c.70710@fx09.iad>
<uereqt$1qg8s$2@dont-email.me> <0ZdQM.67168$3vM.59997@fx37.iad>
<uesbeo$20ej3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 25 Sep 2023 17:47:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="29c8ca5014253eb1ad25f97759b1defd";
logging-data="2147701"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yeFWtTuDYVNr7caXyVjUXkcfaxC0rhmQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:ZQkQ+0m5BJtMPqS48nevY48EBn8=
In-Reply-To: <uesbeo$20ej3$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 25 Sep 2023 17:47 UTC

On 9/25/2023 9:11 AM, Bonita Montero wrote:
> Am 25.09.2023 um 13:15 schrieb Richard Damon:
>
>> You argument is basically, the Standard needs to allow for BAD
>> implementation to exist.
>
> And implementation that throws in this situation isn't bad for me.

Why? We are talking about intra-process sync here. Now, inter-process is
a completely different story...

Re: Thread-safe initialization of static objects

<uesh6f$21hbl$2@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 10:49:03 -0700
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <uesh6f$21hbl$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me>
<37dbe3b6-ead0-487b-884c-197124888eben@googlegroups.com>
<uepvs7$1ff81$3@dont-email.me>
<297dc716-d4df-441e-a711-fe1ebe760ad5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 25 Sep 2023 17:49:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="29c8ca5014253eb1ad25f97759b1defd";
logging-data="2147701"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/od8ZymUt2xvxP8HYRJBu7xHX04ZCxc3k="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:te9U6wMyT6qsPrUhDfMf2PQDk6k=
In-Reply-To: <297dc716-d4df-441e-a711-fe1ebe760ad5n@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 25 Sep 2023 17:49 UTC

On 9/25/2023 10:15 AM, Michael S wrote:
> On Sunday, September 24, 2023 at 9:41:29 PM UTC+3, Chris M. Thomasson wrote:
>> On 9/24/2023 2:50 AM, Michael S wrote:
>>> On Sunday, September 24, 2023 at 11:09:31 AM UTC+3, Bonita Montero wrote:
>>>> Am 24.09.2023 um 05:05 schrieb Chris M. Thomasson:
>>>>
>>>>> Why do you think that static initialization must use a std::mutex
>>>>> anyway? ...
>>>>
>>>> Call it std::mutex or whatever. It is mandated that contenders
>>>> are sleeping - that's not possible without sth. else than a mutex.
>>>
>>> Few dozens posts above I demonstrated an implementation
>>> for pre-Vista Windows where contenders are sleeping just fine and
>>> waking just fine and initialization of different objects proceeds
>>> simultaneously just fine. And it does not use mutex for that.
>>> It uses SleepEx() for wait and QueueUserApc() for wakeup.
>>
>> Why? APC's open up a big can of worms.
>>
>
> Because for pre-Vista I can't think about better solution.
> https://groups.google.com/g/comp.lang.c++/c/bTiLC2zWR4M/m/XG1aWCEDAAAJ
> And frankly I see no worms.

If you know how to properly use APC's, then you should be alright.

>
>>
>>> It uses one global mutex (in form of critical section) for a short
>>> while for metadata updates, but that's done for simplicity and
>>> practicality rather than out of necessity. I am pretty sure that
>>> with enough effort I can device a variant that achieves the same
>>> with CaS.

Re: Thread-safe initialization of static objects

<uesh8j$21hbl$3@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 10:50:10 -0700
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <uesh8j$21hbl$3@dont-email.me>
References: <udafjf$2joeq$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> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 25 Sep 2023 17:50:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="29c8ca5014253eb1ad25f97759b1defd";
logging-data="2147701"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0rrxdTzUkKRuHY6LhmPEm20M423fJDnU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:RxYcC/XargtU1Oo8PpfvXmcafZA=
In-Reply-To: <ZYdQM.67167$3vM.17655@fx37.iad>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 25 Sep 2023 17:50 UTC

On 9/25/2023 4:15 AM, Richard Damon wrote:
> On 9/25/23 4:00 AM, Bonita Montero wrote:
>> Am 25.09.2023 um 03:15 schrieb Richard Damon:
>>
>>> Not for pthreads, ...
>>
>> The standard honors plattforms where an error may arise,
>> so it should also do that for static initialization.
>>
>
> So, you admit you lied when you said the problem you claimed applied to
> ALL operating systems.
>
> The reason the Standard allows Mutex lock to throw the error is because
> in some cases you might get an error, normally in response to a
> programmer error.
>
> The Standard just doesn't allow the implementation to use a Mutex in
> those error conditions for initialization syncronization.
>
> Again, you are showing your ignorance by insisting that the Standard
> give leniency to the implementation to allow it to do things wrong.

Basically, you are correct here.

Re: Thread-safe initialization of static objects

<ueshfm$21hbl$4@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 10:53:57 -0700
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <ueshfm$21hbl$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me>
<37dbe3b6-ead0-487b-884c-197124888eben@googlegroups.com>
<uepvs7$1ff81$3@dont-email.me>
<297dc716-d4df-441e-a711-fe1ebe760ad5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 25 Sep 2023 17:53:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="29c8ca5014253eb1ad25f97759b1defd";
logging-data="2147701"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8NRB+8nb/k9RGJ8auUx1X300AjoBCcoM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:DgffXA5atvp1tYd/xLZV8iWrLj4=
Content-Language: en-US
In-Reply-To: <297dc716-d4df-441e-a711-fe1ebe760ad5n@googlegroups.com>
 by: Chris M. Thomasson - Mon, 25 Sep 2023 17:53 UTC

On 9/25/2023 10:15 AM, Michael S wrote:
> On Sunday, September 24, 2023 at 9:41:29 PM UTC+3, Chris M. Thomasson wrote:
>> On 9/24/2023 2:50 AM, Michael S wrote:
>>> On Sunday, September 24, 2023 at 11:09:31 AM UTC+3, Bonita Montero wrote:
>>>> Am 24.09.2023 um 05:05 schrieb Chris M. Thomasson:
>>>>
>>>>> Why do you think that static initialization must use a std::mutex
>>>>> anyway? ...
>>>>
>>>> Call it std::mutex or whatever. It is mandated that contenders
>>>> are sleeping - that's not possible without sth. else than a mutex.
>>>
>>> Few dozens posts above I demonstrated an implementation
>>> for pre-Vista Windows where contenders are sleeping just fine and
>>> waking just fine and initialization of different objects proceeds
>>> simultaneously just fine. And it does not use mutex for that.
>>> It uses SleepEx() for wait and QueueUserApc() for wakeup.
>>
>> Why? APC's open up a big can of worms.
>>
>
> Because for pre-Vista I can't think about better solution.
> https://groups.google.com/g/comp.lang.c++/c/bTiLC2zWR4M/m/XG1aWCEDAAAJ
> And frankly I see no worms.
>
>>
>>> It uses one global mutex (in form of critical section) for a short
>>> while for metadata updates, but that's done for simplicity and
>>> practicality rather than out of necessity. I am pretty sure that
>>> with enough effort I can device a variant that achieves the same
>>> with CaS.

I don't think Relacy can model APC's in its current form, however it can
model a fairly decent number of Windows sync calls. When you get some
free time to burn, check it out! :^) Give it a go, for fun, when you
have nothing to do:

https://github.com/dvyukov/relacy

:^)

Re: Thread-safe initialization of static objects

<20230925110710.882@kylheku.com>

  copy mid

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

  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: Mon, 25 Sep 2023 18:08:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <20230925110710.882@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me>
<aa307383-8415-4e39-9cca-18a0f57bf6f4n@googlegroups.com>
<uep6ss$1b36d$2@dont-email.me> <YAVPM.165857$Hih7.40004@fx11.iad>
<uep94g$1bect$2@dont-email.me> <cd5QM.124661$1B%c.70710@fx09.iad>
<uereqt$1qg8s$2@dont-email.me> <0ZdQM.67168$3vM.59997@fx37.iad>
<uesbeo$20ej3$1@dont-email.me>
Injection-Date: Mon, 25 Sep 2023 18:08:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="597126d75b51c4a1021936afd4da1e2b";
logging-data="2156184"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WeFV8SwPYrsaU4xIsYQD6vqRVHy8nFrc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:enyvjIB4sJWljj/P0W303ObU8dc=
 by: Kaz Kylheku - Mon, 25 Sep 2023 18:08 UTC

On 2023-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 25.09.2023 um 13:15 schrieb Richard Damon:
>
>> You argument is basically, the Standard needs to allow for BAD
>> implementation to exist.
>
> And implementation that throws in this situation isn't bad for me.

An implementation that throws in mutex locks that aren't process-shared
robust mutexes or anything of that sort is a ... sick joke.

--
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

<uesk4u$222nu$1@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 11:39:25 -0700
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <uesk4u$222nu$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <1h7KM.66324$Wk53.59929@fx01.iad>
<udbqs7$2t34f$1@dont-email.me> <udbs1f$2t79o$1@dont-email.me>
<udbtda$2tdm8$1@dont-email.me> <udcf19$2vuf5$1@dont-email.me>
<udd6vm$33f8r$1@dont-email.me> <udd87f$33lr1$1@dont-email.me>
<udd90h$33peq$1@dont-email.me> <udda40$33ub2$1@dont-email.me>
<udg01c$3m3qc$2@dont-email.me> <4OOKM.167484$uEkc.38090@fx35.iad>
<udggc7$3ou77$1@dont-email.me> <1a2LM.1449512$GMN3.489417@fx16.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 25 Sep 2023 18:39:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="29c8ca5014253eb1ad25f97759b1defd";
logging-data="2165502"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GDcXeMQsfDyqDozSIB+JcesOkyyJeURk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:uWJyZSEMhwDqV/VkjawPcxhY/bM=
In-Reply-To: <1a2LM.1449512$GMN3.489417@fx16.iad>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 25 Sep 2023 18:39 UTC

On 9/9/2023 10:44 AM, Pavel wrote:
> Chris M. Thomasson wrote:
>> On 9/8/2023 5:14 PM, Pavel wrote:
>>> Chris M. Thomasson wrote:
>>>> On 9/7/2023 1:00 PM, Bonita Montero wrote:
>>>>> Am 07.09.2023 um 21:41 schrieb Chris M. Thomasson:
>>>>>
>>>>>> Yup. It uses address based hashing into the fixed mutex table.
>>>>>
>>>>> I guess that's not used at all in the runtimes.
>>>>>
>>>>
>>>> Why not?
>>>
>>> I think it's not needed in general for static initialization purpose.
>>>
>>> This is because, if our design choice for our "C++ compiler" is to
>>> use a dedicated mutex (or once_flag control) per a static variable
>>> that requires dynamic initialization, nothing prevents our compiler
>>> from allocating a static instance of such mutex or control next to
>>> the static variable.
>>>
>>> Because mutex and once_flag can be constant-initialized (at least in
>>> POSIX, notably Linux), the code that dynamically initializes a
>>> variable can directly use the address of its respective
>>> constant-initialized mutex or control, as in the following example:
>>>
>>> code in C++ source file:
>>>
>>> static type1 var1 = InitVar1();
>>>
>>> **pseudo-code** actually generated by the compiler:
>>>
>>> pthread_once_t __var1_once_control = PTHREAD_ONCE_INIT; /* generated
>>> by the compiler when  */
>>>
>>> static type1 var1 = InitVar1(); /* this is compiled to,
>>> **in pseudo-code**, to something like
>>>
>>>   pthread_once( [&var1]() { var1 = InitVar1(); } );
>>> */
>>
>> pthread_once is perfectly fine. Just wondering, are you creating the
>> POSIX impl directly here?
> I am not creating, just demonstrating in pseudo-code how Linux
> implementation could work.
>

That is perfectly fine. Thanks, Pavel. :^)

Re: Thread-safe initialization of static objects

<JJoQM.19136$EIy4.15229@fx48.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx48.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> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me>
<aa307383-8415-4e39-9cca-18a0f57bf6f4n@googlegroups.com>
<uep6ss$1b36d$2@dont-email.me> <YAVPM.165857$Hih7.40004@fx11.iad>
<uep94g$1bect$2@dont-email.me> <cd5QM.124661$1B%c.70710@fx09.iad>
<uereqt$1qg8s$2@dont-email.me> <0ZdQM.67168$3vM.59997@fx37.iad>
<uesbeo$20ej3$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <uesbeo$20ej3$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 11
Message-ID: <JJoQM.19136$EIy4.15229@fx48.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: Mon, 25 Sep 2023 19:29:45 -0400
X-Received-Bytes: 2021
 by: Richard Damon - Mon, 25 Sep 2023 23:29 UTC

On 9/25/23 12:11 PM, Bonita Montero wrote:
> Am 25.09.2023 um 13:15 schrieb Richard Damon:
>
>> You argument is basically, the Standard needs to allow for BAD
>> implementation to exist.
>
> And implementation that throws in this situation isn't bad for me.

So, you don't mind you code not working as promised.

I guess you don't have to write code that actually works.

Re: Thread-safe initialization of static objects

<LJoQM.19137$EIy4.5875@fx48.iad>

  copy mid

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

  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!fx48.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<LWINM.13017$ZkX3.12109@fx09.iad> <ue8mn0$q534$4@dont-email.me>
<uY5OM.30730$Yxl8.13078@fx14.iad> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<mzkPM.16155$ugs.3977@fx36.iad> <uekler$bqj8$1@dont-email.me>
<20230922111441.730@kylheku.com> <uelq9h$lo9j$2@dont-email.me>
<20230923041951.728@kylheku.com> <uemlbj$pl2d$1@dont-email.me>
<20230923185708.811@kylheku.com> <ueoqpa$19436$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
<ZYdQM.67167$3vM.17655@fx37.iad> <uerv9b$1tqis$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
Content-Language: en-US
In-Reply-To: <uerv9b$1tqis$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 34
Message-ID: <LJoQM.19137$EIy4.5875@fx48.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: Mon, 25 Sep 2023 19:29:47 -0400
X-Received-Bytes: 2635
 by: Richard Damon - Mon, 25 Sep 2023 23:29 UTC

On 9/25/23 8:43 AM, Bonita Montero wrote:
> Am 25.09.2023 um 13:15 schrieb Richard Damon:
>
>> So, you admit you lied when you said the problem you claimed applied
>> to ALL operating systems.
>
> I never said that.

LIE

Question:
>> Name one platform for which it is not guaranteed and that targets a
compliant C++11+ implementation.

You Answer

>Any platform since lock() and unlock() might throw system_error()
as documented.

So the platfor for which you claim has the problem, is "Any Platform",
amd thus ALL platforms.

Either that, you your statement is just a deception and thus also a lie.

>
>> The reason the Standard allows Mutex lock to throw the error is
>> because  in some cases you might get an error, normally in response
>> to a programmer error.
>
> You don't know that.

no, YOU don't know what you are talking about, since you just prove you
are a liar.

Re: Thread-safe initialization of static objects

<mLqQM.164530$1B%c.83768@fx09.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$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>
<LWINM.13017$ZkX3.12109@fx09.iad> <ue8mn0$q534$4@dont-email.me>
<uY5OM.30730$Yxl8.13078@fx14.iad> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<VnsPM.122464$Hih7.52058@fx11.iad> <uelqeq$lo9j$4@dont-email.me>
<XbJPM.157838$Hih7.40116@fx11.iad> <ueo5ps$163k0$1@dont-email.me>
<Y3_PM.16749$E_d1.14707@fx04.iad> <ueqfec$1i6un$1@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <ueqfec$1i6un$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 20
Message-ID: <mLqQM.164530$1B%c.83768@fx09.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 26 Sep 2023 01:48:02 UTC
Date: Mon, 25 Sep 2023 21:47:53 -0400
X-Received-Bytes: 2485
 by: Pavel - Tue, 26 Sep 2023 01:47 UTC

Bonita Montero wrote:
> Am 24.09.2023 um 19:10 schrieb Pavel:
>
>> so? everyone has been telling you initialization of simple mutices
>> does  not fail. After few hundred posts, you decided to agree?
>
> lock() and unlock() might throw system_error.
>
>
On *some* C++ mutex the lock() method might throw. This does not matter
because such C++ mutex:

a. does not have to be used for C++ static initialization; and
b. is not the best solution for C++ static initialization (in
particular, not the best-performing solution); and
c. is not in fact used for C++ static initialization on common platforms
we could check.

Therefore, it is not necessary to change the C++ standard and allow
static initialization to throw.

Re: Thread-safe initialization of static objects

<KOqQM.164531$1B%c.12737@fx09.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$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> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <ueqfkl$1i6un$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 12
Message-ID: <KOqQM.164531$1B%c.12737@fx09.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 26 Sep 2023 01:51:38 UTC
Date: Mon, 25 Sep 2023 21:51:38 -0400
X-Received-Bytes: 2107
 by: Pavel - Tue, 26 Sep 2023 01:51 UTC

Bonita Montero wrote:
> Am 24.09.2023 um 18:47 schrieb Pavel:
>> Bonita Montero wrote:
>
>> Name one platform for which it is not guaranteed and that targets a
>> compliant C++11+ implementation.
>
> Any platform since lock() and unlock() might throw system_error()
> as documented.
>
This does not matter as long as C++ static initialization can be
implemented as specified.

Re: Thread-safe initialization of static objects

<TQqQM.164532$1B%c.109462@fx09.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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>
<LWINM.13017$ZkX3.12109@fx09.iad> <ue8mn0$q534$4@dont-email.me>
<uY5OM.30730$Yxl8.13078@fx14.iad> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<mzkPM.16155$ugs.3977@fx36.iad> <uekler$bqj8$1@dont-email.me>
<20230922111441.730@kylheku.com> <uelq9h$lo9j$2@dont-email.me>
<20230923041951.728@kylheku.com> <uemlbj$pl2d$1@dont-email.me>
<20230923185708.811@kylheku.com> <ueoqpa$19436$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <uerem0$1qg8s$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 10
Message-ID: <TQqQM.164532$1B%c.109462@fx09.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 26 Sep 2023 01:53:55 UTC
Date: Mon, 25 Sep 2023 21:53:55 -0400
X-Received-Bytes: 2097
 by: Pavel - Tue, 26 Sep 2023 01:53 UTC

Bonita Montero wrote:
> Am 25.09.2023 um 03:15 schrieb Richard Damon:
>
>> Not for pthreads, ...
>
> The standard honors plattforms where an error may arise,
> so it should also do that for static initialization.
>
The standard does not honor platforms, it's the C++ implementation on a
platform might or might not honor the standard.

Re: Thread-safe initialization of static objects

<uetk8d$2b8q6$1@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 20:47:24 -0700
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <uetk8d$2b8q6$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<LWINM.13017$ZkX3.12109@fx09.iad> <ue8mn0$q534$4@dont-email.me>
<uY5OM.30730$Yxl8.13078@fx14.iad> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<mzkPM.16155$ugs.3977@fx36.iad> <uekler$bqj8$1@dont-email.me>
<20230922111441.730@kylheku.com> <uelq9h$lo9j$2@dont-email.me>
<20230923041951.728@kylheku.com> <uemlbj$pl2d$1@dont-email.me>
<20230923185708.811@kylheku.com> <ueoqpa$19436$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
<ZYdQM.67167$3vM.17655@fx37.iad> <uerv9b$1tqis$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Sep 2023 03:47:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2466630"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EUfIMUkeJDwF/7VGeViB3jkT9GQTem80="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:zrD76NEW46xFRrNZydM6vKDzf6E=
In-Reply-To: <uerv9b$1tqis$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 03:47 UTC

On 9/25/2023 5:43 AM, Bonita Montero wrote:
> Am 25.09.2023 um 13:15 schrieb Richard Damon:
>
>> So, you admit you lied when you said the problem you claimed applied
>> to ALL operating systems.
>
> I never said that.

Oh, that is rather rich!!! Yikes!

>
>> The reason the Standard allows Mutex lock to throw the error is
>> because  in some cases you might get an error, normally in response
>> to a programmer error.
>
> You don't know that.

Re: Thread-safe initialization of static objects

<uetl3q$2bd8t$1@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 21:01:59 -0700
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <uetl3q$2bd8t$1@dont-email.me>
References: <udafjf$2joeq$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> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <TQqQM.164532$1B%c.109462@fx09.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 04:02:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2471197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mtAinduzUdb2a0DU7wqrJrz5hS5+mibw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:I3Cdil92vV8UI9lRWBSW9vLHPMY=
Content-Language: en-US
In-Reply-To: <TQqQM.164532$1B%c.109462@fx09.iad>
 by: Chris M. Thomasson - Tue, 26 Sep 2023 04:01 UTC

On 9/25/2023 6:53 PM, Pavel wrote:
> Bonita Montero wrote:
>> Am 25.09.2023 um 03:15 schrieb Richard Damon:
>>
>>> Not for pthreads, ...
>>
>> The standard honors plattforms where an error may arise,
>> so it should also do that for static initialization.
>>
> The standard does not honor platforms, it's the C++ implementation on a
> platform might or might not honor the standard.

Ding! You got it, Pavel. :^)

Let's say I have a new experimental system that I want to be able to
work with POSIX. Therefore, I need to create all of the necessary
machinery to make it a reality, so to speak. I even have to create a
special C compiler for my new system to help things move along... This
would be the work that I have to put into gaining an actual
implementation that adheres to POSIX and C while providing all of the
required APIs...

I need to make damn sure that they all work according to POSIX. If I
want to create a C++/C 11 impl, I can perhaps even use the POSIX port
for it. You never know. ;^)

I think this aligns okay with your main point, Pavel?

:^)

Re: Thread-safe initialization of static objects

<uetn46$2bkun$1@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 06:36:24 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <uetn46$2bkun$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 04:36:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2479063"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Idfsgr6UYsJsKx4FyX+U9w6apZzC0Xww="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7roppIQdGOJGnZVJAa6sBHvgcJM=
Content-Language: de-DE
In-Reply-To: <LJoQM.19137$EIy4.5875@fx48.iad>
 by: Bonita Montero - Tue, 26 Sep 2023 04:36 UTC

Am 26.09.2023 um 01:29 schrieb Richard Damon:

> >Any platform since lock() and unlock() might throw system_error()
> as documented.

I meant to say that this is something to be expected on any platform,
not that it actually happens.

Re: Thread-safe initialization of static objects

<20230925214046.531@kylheku.com>

  copy mid

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

  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: Tue, 26 Sep 2023 04:52:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <20230925214046.531@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <ue7f6g$frod$2@dont-email.me>
<LWINM.13017$ZkX3.12109@fx09.iad> <ue8mn0$q534$4@dont-email.me>
<uY5OM.30730$Yxl8.13078@fx14.iad> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<mzkPM.16155$ugs.3977@fx36.iad> <uekler$bqj8$1@dont-email.me>
<20230922111441.730@kylheku.com> <uelq9h$lo9j$2@dont-email.me>
<20230923041951.728@kylheku.com> <uemlbj$pl2d$1@dont-email.me>
<20230923185708.811@kylheku.com> <ueoqpa$19436$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
<ZYdQM.67167$3vM.17655@fx37.iad> <uerv9b$1tqis$1@dont-email.me>
<LJoQM.19137$EIy4.5875@fx48.iad> <uetn46$2bkun$1@dont-email.me>
Injection-Date: Tue, 26 Sep 2023 04:52:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="84073cef60c20381e418356514cfa3d7";
logging-data="2483515"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+gAZtgGIjW1bB9Os7N1xTYdblMuBrA64="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:MBmNxEZwFkJSq1ezzWcZc1lD6Zc=
 by: Kaz Kylheku - Tue, 26 Sep 2023 04:52 UTC

On 2023-09-26, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 26.09.2023 um 01:29 schrieb Richard Damon:
>
>> >Any platform since lock() and unlock() might throw system_error()
>> as documented.
>
> I meant to say that this is something to be expected on any platform,
> not that it actually happens.

Not in a correct program which is free of misuses of locks!

Misuses like: deadlocks; unlocking locks not owned by caller; using
locks which have not yet been initialized, or have been destroyed or are
corrupt.

If you're getting a system_error from a mutex operation, you should
debug that. Trying to recover from such a thing and continue is going to
be a giant hack.

Catching exceptions that are bugs is hostile to debugging with other
techniques; C++ exceptions unwind, which throws away information about
what went wrong where.

--
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

<uetrjn$2car5$1@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 22:52:52 -0700
Organization: A noiseless patient Spider
Lines: 86
Message-ID: <uetrjn$2car5$1@dont-email.me>
References: <udafjf$2joeq$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> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <20230924092501.340@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 05:52:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2501477"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+om91C6KeIXcYyP+AkRac+pz+tcZO99ho="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:h+jksq+v8LKPQIncA2hQbSnpBbo=
Content-Language: en-US
In-Reply-To: <20230924092501.340@kylheku.com>
 by: Chris M. Thomasson - Tue, 26 Sep 2023 05:52 UTC

On 9/24/2023 10:04 AM, Kaz Kylheku wrote:
> On 2023-09-24, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 24.09.2023 um 04:22 schrieb Kaz Kylheku:
>>
>>> A possible design is that each *thread* has a wait semaphore.
>>
>> You'd have to register the binary semaphore and register as a waiter in
>> one atomic step. You could do that with a DCAS'd ring, but you coudn't
>> atomically update the link pointers of the other nodes at the same
>> time you update the roots link pointers. And you would have the deallo-
>> cation poblem, i.e. the memory of your object may never be deallocated.
>
> Now you're just throwing together words you don't understand.
>
>> Show me your implementation !
>
> E.g. old LinuxThreads in glibc, circa 2000:
>
> https://sourceware.org/git/?p=glibc.git;a=blob;f=linuxthreads/spinlock.c;h=5cd772602c8858edd8238e73eefcbf2758935d74;hb=d82e4c7bb231c9e0f835bd46467563ac3b56cebe
>
> The low level __pthread_lock and __pthread_unlock functions maintain a
> queue, using a single-word atomic CAS.
>
> There are suspend() and resume() functions for the waiting;
> they are elsewhere.
>
> If you look in restart.h you can see that those operations are defined
> in two different ways, both of which use signals (not a semaphore per
> thread). A suspending thread waits for the arrival of a signal,
> resume is done by sending a signal. That's kind of semaphore-like;
> and POSIX real-time signals can even queue up, like a counting sem.
>
>> It's ridiculous because mutex are a cheap resource. And if such imple-
>> mentation would be possible the standard shouldn't mandate it since
>> not every platform has a DCAS.
>
> Things can be done in ways you havn't thought about.
>
> Atomic operations aren't required to achieve mutual exclusion among
> processors that share memory.
>
> As someone continually insisting on having expertise in concurrency,
> you must be familiar with the research work of Leslie Lamport?

Iirc, that uses atomic loads, stores and membars. Iirc, it requires a
#StoreLoad barrier on the SPARC. Iirc, it even requires an explicit
membar on the x86. MFENCE, or XCHG which has the lock prefix
automatically asserted. Humm... There is a way to get around that
bastard #StoreLoad membar... It uses an async sync setup. The funny
thing is that Windows has a API that can be used to actually implement
it! Try to think of a so called, remote memory barrier, in a sense:

https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushprocesswritebuffers

There is a way to use this to get an async mutex that is kind of sort of
akin to a read write mutex. Basically, the mutex is broken down into two
parts. One that represents accesses that _very_ frequently called upon.
The other one is used rather rarely. This is the async nature that can
be exploited in rather interesting ways. I implemented some in the past
with Dmitry Vyukov. Also, this FlushProcessWriteBuffers API can be used
to implement other rather exotic sync schemes. They have very excellent
performance for certain workloads. Actually, there is a way to use it to
get a RCU in userspace and/or hazard pointers without any explicit
#StoreLoad membars.

>
> For instance, the paper _A Fast Mutual Exclusion Algorithm_ [1985].
>
> Abstract:
>
> "A new solution to the mutual exclusion problem is presented that, in the
> absence of contention, requires only seven memory accesses. It assumes
> atomic reads and atomic writes to shared registers."
>
> Snipeet from Introduction which gives a clue as to the motivation:
>
> "Recently, there has arisen interest in building shared-memory
> multiprocessor computers by connecting standard processors and
> memories, with as little modification to the hardware as possible.
> Because ordinary sequential processors and memories do not have atomic
> test-and-set operations, it is worth investigating whether
> shared-memory mutual exclusion algorithms are a practical alternative."
>

Re: Thread-safe initialization of static objects

<uetshq$2cf69$1@dont-email.me>

  copy mid

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

  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: Mon, 25 Sep 2023 23:08:56 -0700
Organization: A noiseless patient Spider
Lines: 116
Message-ID: <uetshq$2cf69$1@dont-email.me>
References: <udafjf$2joeq$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> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <20230924092501.340@kylheku.com>
<uetrjn$2car5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Sep 2023 06:08:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2505929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x3RiamIej//C12I01o+gtnOjG+IfRmyk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:E8nltCPnpjZSN7VqnLi6BQ62Pt8=
In-Reply-To: <uetrjn$2car5$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 06:08 UTC

On 9/25/2023 10:52 PM, Chris M. Thomasson wrote:
> On 9/24/2023 10:04 AM, Kaz Kylheku wrote:
>> On 2023-09-24, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> Am 24.09.2023 um 04:22 schrieb Kaz Kylheku:
>>>
>>>> A possible design is that each *thread* has a wait semaphore.
>>>
>>> You'd have to register the binary semaphore and register as a waiter in
>>> one atomic step. You could do that with a DCAS'd ring, but you coudn't
>>> atomically update the link pointers of the other nodes at the same
>>> time you update the roots link pointers. And you would have the deallo-
>>> cation poblem, i.e. the memory of your object may never be deallocated.
>>
>> Now you're just throwing together words you don't understand.
>>
>>> Show me your implementation !
>>
>> E.g. old LinuxThreads in glibc, circa 2000:
>>
>> https://sourceware.org/git/?p=glibc.git;a=blob;f=linuxthreads/spinlock.c;h=5cd772602c8858edd8238e73eefcbf2758935d74;hb=d82e4c7bb231c9e0f835bd46467563ac3b56cebe
>>
>> The low level __pthread_lock and __pthread_unlock functions maintain a
>> queue, using a single-word atomic CAS.
>>
>> There are suspend() and resume() functions for the waiting;
>> they are elsewhere.
>>
>> If you look in restart.h you can see that those operations are defined
>> in two different ways, both of which use signals (not a semaphore per
>> thread). A suspending thread waits for the arrival of a signal,
>> resume is done by sending a signal. That's kind of semaphore-like;
>> and POSIX real-time signals can even queue up, like a counting sem.
>>
>>> It's ridiculous because mutex are a cheap resource. And if such imple-
>>> mentation would be possible the standard shouldn't mandate it since
>>> not every platform has a DCAS.
>>
>> Things can be done in ways you havn't thought about.
>>
>> Atomic operations aren't required to achieve mutual exclusion among
>> processors that share memory.
>>
>> As someone continually insisting on having expertise in concurrency,
>> you must be familiar with the research work of Leslie Lamport?
>
> Iirc, that uses atomic loads, stores and membars. Iirc, it requires a
> #StoreLoad barrier on the SPARC. Iirc, it even requires an explicit
> membar on the x86. MFENCE, or XCHG which has the lock prefix
> automatically asserted. Humm... There is a way to get around that
> bastard #StoreLoad membar... It uses an async sync setup. The funny
> thing is that Windows has a API that can be used to actually implement
> it! Try to think of a so called, remote memory barrier, in a sense:
>
> https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushprocesswritebuffers
>
> There is a way to use this to get an async mutex that is kind of sort of
> akin to a read write mutex. Basically, the mutex is broken down into two
> parts. One that represents accesses that _very_ frequently called upon.
> The other one is used rather rarely. This is the async nature that can
> be exploited in rather interesting ways. I implemented some in the past
> with Dmitry Vyukov. Also, this FlushProcessWriteBuffers API can be used
> to implement other rather exotic sync schemes. They have very excellent
> performance for certain workloads. Actually, there is a way to use it to
> get a RCU in userspace and/or hazard pointers without any explicit
> #StoreLoad membars.

The idea is that the "fast" part of the mutex allows threads to access
shared data without using any memory barriers, "usually" read only...
The "slow" part of the async mutex checks some things, reports its
intent then issues a FlushProcessWriteBuffers to sync up with the fast
part. This is basically akin to RCU, in a sense. Have you experimented
with the rather "exotic" async mutexes before? RCU is geared toward
giving reads full speed ahead captain, and writers are sort of second
class citizens. So, it's also async in a way...

There is a way to use FlushProcessWriteBuffers to create a "quiescent"
state, ala RCU, wrt memory visibility.

There is an interesting paper that described a technique, iirc, its
called QPI or something. That tried to "abuse" an x86 to generate remote
memory barriers. Iirc, they intentionally use unaligned accesses to
trigger a BUS lock. I need to find that damn paper! :^) I read it
before! damn it.

Thanks for sparking my mind on this. It's been a while Kaz. :^)

>
>
>
>>
>> For instance, the paper _A Fast Mutual Exclusion Algorithm_ [1985].
>>
>> Abstract:
>>
>>    "A new solution to the mutual exclusion problem is presented that,
>> in the
>>     absence of contention, requires only seven memory accesses. It
>> assumes
>>     atomic reads and atomic writes to shared registers."
>>
>> Snipeet from Introduction which gives a clue as to the motivation:
>>
>>    "Recently, there has arisen interest in building shared-memory
>>     multiprocessor computers by connecting standard processors and
>>     memories, with as little modification to the hardware as possible.
>>     Because ordinary sequential processors and memories do not have
>> atomic
>>     test-and-set operations, it is worth investigating whether
>>     shared-memory mutual exclusion algorithms are a practical
>> alternative."
>>
>

Re: Thread-safe initialization of static objects

<ueu52o$2dv5f$1@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 10:34:33 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ueu52o$2dv5f$1@dont-email.me>
References: <udafjf$2joeq$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> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <VnsPM.122464$Hih7.52058@fx11.iad>
<uelqeq$lo9j$4@dont-email.me> <XbJPM.157838$Hih7.40116@fx11.iad>
<ueo5ps$163k0$1@dont-email.me> <Y3_PM.16749$E_d1.14707@fx04.iad>
<ueqfec$1i6un$1@dont-email.me> <mLqQM.164530$1B%c.83768@fx09.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 08:34:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2555055"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4iQpyWrdIymnWHi8ZkgMeIDoK4mu6rhg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ZF82pKeM8jov+mIs0F98GRq5MPc=
In-Reply-To: <mLqQM.164530$1B%c.83768@fx09.iad>
Content-Language: de-DE
 by: Bonita Montero - Tue, 26 Sep 2023 08:34 UTC

Am 26.09.2023 um 03:47 schrieb Pavel:

> On *some* C++ mutex the lock() method might throw. This does not matter
> because such C++ mutex:

That's enough to expect that to be portable.

> a. does not have to be used for C++ static initialization; ...

I already mentioned that myself, but if there's some other kind of
mutex this also *may* happen on some platforms. Therefore it should
be defined this way.

Re: Thread-safe initialization of static objects

<ueu77t$2ebas$1@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 11:11:27 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ueu77t$2ebas$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <20230925214046.531@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 09:11:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2567516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9826/SevIx1ACChRZz1fXB1heQjCX8nI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:erP1VGB5DmBb7DQdmnxn2xpzx8A=
In-Reply-To: <20230925214046.531@kylheku.com>
Content-Language: de-DE
 by: Bonita Montero - Tue, 26 Sep 2023 09:11 UTC

Am 26.09.2023 um 06:52 schrieb Kaz Kylheku:

> Not in a correct program which is free of misuses of locks!

This is your name based on individual operating systems.
This assumption is not portable.

> If you're getting a system_error from a mutex operation, you should
> debug that. ...

The constructor is noexcept, so locking has to do the delayed
initialization for the slow path on contention. This delayed
initialization can fail.

Re: Thread-safe initialization of static objects

<3bzQM.36476$q0k.14387@fx34.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx34.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <ue7f6g$frod$2@dont-email.me>
<LWINM.13017$ZkX3.12109@fx09.iad> <ue8mn0$q534$4@dont-email.me>
<uY5OM.30730$Yxl8.13078@fx14.iad> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<mzkPM.16155$ugs.3977@fx36.iad> <uekler$bqj8$1@dont-email.me>
<20230922111441.730@kylheku.com> <uelq9h$lo9j$2@dont-email.me>
<20230923041951.728@kylheku.com> <uemlbj$pl2d$1@dont-email.me>
<20230923185708.811@kylheku.com> <ueoqpa$19436$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
<ZYdQM.67167$3vM.17655@fx37.iad> <uerv9b$1tqis$1@dont-email.me>
<LJoQM.19137$EIy4.5875@fx48.iad> <uetn46$2bkun$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
Content-Language: en-US
In-Reply-To: <uetn46$2bkun$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 21
Message-ID: <3bzQM.36476$q0k.14387@fx34.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: Tue, 26 Sep 2023 07:23:43 -0400
X-Received-Bytes: 2476
 by: Richard Damon - Tue, 26 Sep 2023 11:23 UTC

On 9/26/23 12:36 AM, Bonita Montero wrote:
> Am 26.09.2023 um 01:29 schrieb Richard Damon:
>
>>  >Any platform since lock() and unlock() might throw system_error()
>> as documented.
>
> I meant to say that this is something to be expected on any platform,
> not that it actually happens.
>
>

But it doesn't NEED to be expected, and doing it in a way that allows
for failure when you can do it in a way that can't fail is just being a
bad implementation.

Is your problem that you, yourself, don't know how to do it, and you
think the Standard needs to degrade the promises given to allow for your
"broken" methods to be used?

WHy don't you understand that, at least for here, failure is not an
option, and no failure is achievable.

Re: Thread-safe initialization of static objects

<8bzQM.36477$q0k.24969@fx34.iad>

  copy mid

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

  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!fx34.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> <ue8mn0$q534$4@dont-email.me>
<uY5OM.30730$Yxl8.13078@fx14.iad> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<mzkPM.16155$ugs.3977@fx36.iad> <uekler$bqj8$1@dont-email.me>
<20230922111441.730@kylheku.com> <uelq9h$lo9j$2@dont-email.me>
<20230923041951.728@kylheku.com> <uemlbj$pl2d$1@dont-email.me>
<20230923185708.811@kylheku.com> <ueoqpa$19436$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
<ZYdQM.67167$3vM.17655@fx37.iad> <uerv9b$1tqis$1@dont-email.me>
<LJoQM.19137$EIy4.5875@fx48.iad> <uetn46$2bkun$1@dont-email.me>
<20230925214046.531@kylheku.com> <ueu77t$2ebas$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ueu77t$2ebas$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 22
Message-ID: <8bzQM.36477$q0k.24969@fx34.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: Tue, 26 Sep 2023 07:23:48 -0400
X-Received-Bytes: 2447
 by: Richard Damon - Tue, 26 Sep 2023 11:23 UTC

On 9/26/23 5:11 AM, Bonita Montero wrote:
> Am 26.09.2023 um 06:52 schrieb Kaz Kylheku:
>
>> Not in a correct program which is free of misuses of locks!
>
> This is your name based on individual operating systems.
> This assumption is not portable.
>
>> If you're getting a system_error from a mutex operation, you should
>> debug that. ...
>
> The constructor is noexcept, so locking has to do the delayed
> initialization for the slow path on contention. This delayed
> initialization can fail.
>

Nope, if you do it right, a suitable synchronization object can be
created without possibility of error.

Thus, doing something that might fail is just wrong.

You seem to like failing at what you try to do.


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

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor