Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

We are drowning in information but starved for knowledge. -- John Naisbitt, Megatrends


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

<uei1je$3l13h$3@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:21:34 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <uei1je$3l13h$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<DUVOM.87557$noZ7.33800@fx13.iad> <uehdjj$3h8me$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Sep 2023 18:21:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3834993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hE2A7DsQ+eVjKtGxq1p7PwO4pHfb34xo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:Q6F4j8gxYwYELNhxYRmJZ8AMmSs=
Content-Language: en-US
In-Reply-To: <uehdjj$3h8me$3@dont-email.me>
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:21 UTC

On 9/21/2023 5:40 AM, Bonita Montero wrote:
> Am 21.09.2023 um 13:36 schrieb Richard Damon:
>
>> Why?
>
> Because the initialization might only take a microsecond or less
> and a yield is a full timeslice, on Linux and Windows usually one
> millisecond.

An adaptive backoff can be a mixture of the PAUSE instruction aka x86,
and yield wrt the OS.

Re: Thread-safe initialization of static objects

<uei1rg$3l13h$4@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:25:52 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <uei1rg$3l13h$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<DUVOM.87557$noZ7.33800@fx13.iad> <uehdjj$3h8me$3@dont-email.me>
<uehf2o$3hkm3$2@dont-email.me> <uehj9d$3idng$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Sep 2023 18:25:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3834993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kXz25TcCgppqnw9wKEW3mTu0uzevATO4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:jnr+BI3w/1IsC7UVTJ1iilLT8lw=
Content-Language: en-US
In-Reply-To: <uehj9d$3idng$1@dont-email.me>
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:25 UTC

On 9/21/2023 7:17 AM, Bonita Montero wrote:
> Am 21.09.2023 um 15:05 schrieb David Brown:
>
>> "Yield" won't take a timeslice unless there is something else of the
>> same priority, waiting to run on the same core. ...
>
> Ok, you're right, but the code would be still unacceptable under load.
>

Wait, are you talking about a _pure_ spin lock in user space here? For
some reason you seem to be struggling with adaptive backoffs, that can
choose to wait in the kernel for a "really slow path", so to speak. Keep
in mind that spinning is already a slow path by default. Now, there is a
way to organize a program where a yield can be replaced by a
"try_to_do_something_else()" function. Its been a while sense I
implemented one. Man, how time flies!

Re: Thread-safe initialization of static objects

<uei1vb$3l13h$5@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:27:54 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <uei1vb$3l13h$5@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<DUVOM.87557$noZ7.33800@fx13.iad> <uehdjj$3h8me$3@dont-email.me>
<56e77942-b8ec-4e40-97ed-3340a6f2a01an@googlegroups.com>
<uehm0b$3iuv6$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Sep 2023 18:27:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3834993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hoiwNxsY4vIz22E/KJ08ki/MhgIDi/Ys="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:DKP97qVq/YWGS7p+asAkAOx4T1Y=
In-Reply-To: <uehm0b$3iuv6$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:27 UTC

On 9/21/2023 8:03 AM, Bonita Montero wrote:
> Am 21.09.2023 um 16:48 schrieb Michael S:
>
>> If initialization is short then contention is very unlikely.
>
> Maybe, but no one would cose this solutions if mutexes are available.
> Yielding in this situation is crap.
>

You tell em Bonita. You should start protesting about this in front of
Microsoft head quarters in Redmond.

Re: Thread-safe initialization of static objects

<uei233$3l13h$6@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:29:54 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <uei233$3l13h$6@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <uebaoh$271en$8@dont-email.me>
<uebnc1$293m3$5@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Sep 2023 18:29:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3834993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/uFdbvI4mCO+4yRCSH+G7dbB+UkJN+ims="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:j6IUKbhRSF4YERENBtFXu7bp7iE=
Content-Language: en-US
In-Reply-To: <uebnc1$293m3$5@dont-email.me>
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:29 UTC

On 9/19/2023 1:50 AM, Bonita Montero wrote:
> Am 19.09.2023 um 07:14 schrieb Chris M. Thomasson:
>
>> I assume going to "sleep" means waiting in the kernel on a slow path.
>> Otherwise, humm... Are you talking about user logic that sleeps for a
>> second or two? Why should that matter at all? The impl shall arrange
>> things such that there is no deadlock. Let me guess Bonita, you think
>> that user logic that waits for infinity while its trying to initialize
>> itself should be handled in the std? Humm... Not sure about you.
>
> You often seem confused.
>

Really? Actually, my comments here are trying to help you. But, you like
to flush them down the toilet and call me an idiot. Well, shit happens.

Re: Thread-safe initialization of static objects

<uei2cc$3l87c$1@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:34:51 -0700
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <uei2cc$3l87c$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<20230918110147.326@kylheku.com> <uea42g$1sn0e$2@dont-email.me>
<20230918123203.723@kylheku.com> <ueb3q5$2638l$5@dont-email.me>
<20230918205859.263@kylheku.com> <uebn7l$293m3$3@dont-email.me>
<20230919094617.529@kylheku.com> <uecn60$2f5ud$2@dont-email.me>
<20230919140127.732@kylheku.com> <uedpdo$2orvq$5@dont-email.me>
<20230919204410.51@kylheku.com> <uefhkh$3371r$1@dont-email.me>
<uegea8$3bfsj$3@dont-email.me> <ueggj7$3bq3f$2@dont-email.me>
<uegsls$3dj0r$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Sep 2023 18:34:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3842284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192gS0m9ckbs2o/cHOJzWeIXE1Jzy1oSe0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:Rjagd6govNv+fTIl6MmZJqn5bl4=
In-Reply-To: <uegsls$3dj0r$3@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:34 UTC

On 9/21/2023 12:51 AM, Bonita Montero wrote:
> Am 21.09.2023 um 06:25 schrieb Chris M. Thomasson:
>> On 9/20/2023 8:46 PM, Bonita Montero wrote:
>
>>> Am 20.09.2023 um 21:36 schrieb Chris M. Thomasson:
>
>>> A recursive lock is impossible here since the object might have
>>> been partitially initialized and when coming back this partitial
>>> initialization would happen again.
>
>> A recursive would only provide a, so of, false sense of security wrt
>> the infinite recursion that is present in the user code.
>
> A recursive lock wouldn't make sense here since the object might have
> beein partitially created when it re-enters the mutex which guards the
> initialization.
>

Huh? I must be misunderstanding you here. A Recursive mutex means it
allows the same thread to acquire it more than once. It can be detected
rather easily.

Re: Thread-safe initialization of static objects

<uei2ji$3l87c$2@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:38:41 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <uei2ji$3l87c$2@dont-email.me>
References: <udafjf$2joeq$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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<z1MOM.13123$TwR4.1703@fx46.iad> <uegt3a$3dj0r$4@dont-email.me>
<5f5de245-c174-4f2d-9870-6a990123b524n@googlegroups.com>
<ueh0rk$3ebkg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Sep 2023 18:38:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3842284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oFGLz9jYpop2NfLey2YM8JXpLbxO0Jc4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:SSqqNuZCHKquUUfZJWk1ywopgzg=
In-Reply-To: <ueh0rk$3ebkg$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:38 UTC

On 9/21/2023 2:02 AM, Bonita Montero wrote:
> Am 21.09.2023 um 10:38 schrieb Michael S:
>
>> Actually, considering that contention is very rare in practice, ...
>
> The initialization might last an arbitrary time, so spinning
> is inacceptable.
>
>> So even use of Futex | Critical Section | SRW lock,  although it make
>> a lot of sense in practice,  is not necessary from theoretical P.O.V.
>
> Why should a SRW-lock make sense here ? If the object isn't initialized
> iz can't be read meanwhile. And a futex isn't a replacement for a mutex
> but just a faster slow path for a mutex.
>
>
>

A futex can be used to build a mutex, semaphore, a condition variable,
ect... A futex is a nice building block that works out pretty damn good.

Have a lock-free algorithm that you want to make block on certain
conditions, build a predicate and we can use it with a futex.

Re: Thread-safe initialization of static objects

<20230921112123.105@kylheku.com>

  copy mid

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

  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: Thu, 21 Sep 2023 18:39:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <20230921112123.105@kylheku.com>
References: <udafjf$2joeq$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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<z1MOM.13123$TwR4.1703@fx46.iad> <uegt3a$3dj0r$4@dont-email.me>
<5f5de245-c174-4f2d-9870-6a990123b524n@googlegroups.com>
<ueh0rk$3ebkg$1@dont-email.me>
<3af7b0b8-cfca-47d7-82cf-0d2bd3b8b321n@googlegroups.com>
<ueh8s7$3gh0c$1@dont-email.me>
<bed7f83a-18a0-4b4a-bb8c-cb8ff4a72ab4n@googlegroups.com>
<ueheuu$3hkm3$1@dont-email.me>
<bbde3ce4-b969-431e-a3f6-d0b5ec6aafacn@googlegroups.com>
<uei0u9$3l0uh$1@dont-email.me>
Injection-Date: Thu, 21 Sep 2023 18:39:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d3d54e4b74191d06bda8ef3fd3367eb7";
logging-data="3843994"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+T95HT3SQ98ehi8heiE6Hy6KDPqCYABx8="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:VIj/kZ6XhKffEvMMxo0RZnGDg4I=
 by: Kaz Kylheku - Thu, 21 Sep 2023 18:39 UTC

On 2023-09-21, David Brown <david.brown@hesbynett.no> wrote:
> But I think for that kind of system, your recommended solution - don't
> have function-local statics that need such initialisation
> synchronisation - is far and away the most common solution.

It could be as simple as putting the same variable outside of the
function, so that the global construction takes care of it.

I don't think that global construction/initialization in C++ is a very
good feature. You often need to maintain a strict order among
global initializations. The order of global constructions is basically
left to chance. It might follow the order in which the object files
were linked or whatever.

Only initializations that have absolutely no dependencies can be
confidently put into the global scope.

A possible reason why some programmers put complex static
initializations into a block scope is to delay that initialization,
since it will happen at a time when all the global ones have done.

In my experience, global initialization can sometimes grow complex and
need to be broken into phases: early initialization, late
initialization. Possibly more than two.

Block scope static initialization could be serving as an /ad hoc/
late initialization.

--

I wonder whether anyone has ever experimented with a way of controlling
the order of global C++ initializations by manipulating link order.

Say that in a given implementation we can rely on the fact that if
object files a.o b.o c.o are linked in that order, then their global
constructions are done in that order.

We could then deduce the dependencies among them (say, from
header file inclusions: if b.cc includes "a.h", but a.cc does not
include "b.h", we can infer that b depends on a). Then topologically
sort the .o files accordingly.

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

<uei2mh$3l87c$3@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:40:17 -0700
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <uei2mh$3l87c$3@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> <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> <20230917123203.524@kylheku.com>
<ue8lst$q25a$2@dont-email.me> <20230918101705.91@kylheku.com>
<uea1rj$1saml$1@dont-email.me> <hK5OM.30729$Yxl8.9621@fx14.iad>
<ueb3f7$2638l$2@dont-email.me> <z1MOM.13123$TwR4.1703@fx46.iad>
<uegt3a$3dj0r$4@dont-email.me>
<5f5de245-c174-4f2d-9870-6a990123b524n@googlegroups.com>
<ueh0rk$3ebkg$1@dont-email.me>
<3af7b0b8-cfca-47d7-82cf-0d2bd3b8b321n@googlegroups.com>
<ueh8s7$3gh0c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Sep 2023 18:40:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3842284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+92JvyB+eWK1xMJhwnslqlZNSUYdajdI8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:clD5hRV7WValAPYjia6aeKqYVs0=
Content-Language: en-US
In-Reply-To: <ueh8s7$3gh0c$1@dont-email.me>
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:40 UTC

On 9/21/2023 4:19 AM, David Brown wrote:
> On 21/09/2023 11:59, Michael S wrote:
>> On Thursday, September 21, 2023 at 12:03:01 PM UTC+3, Bonita Montero
>> wrote:
>>> Am 21.09.2023 um 10:38 schrieb Michael S:
>>>
>>>> Actually, considering that contention is very rare in practice, ...
>>>
>>> The initialization might last an arbitrary time, so spinning
>>> is inacceptable.
>>
>> Why is it unacceptable? The impact of needless wake up of the waiting
>> thread
>> once per tick is negligible in terms of system performance and not too
>> horrible in terms power consumption. The impact of needless sleep till
>> the
>> next tick is also insignificant under assumption that initialization
>> took long time.
>>
>> I'd call it non-ideal when better solutions available, but perfectly
>> acceptable otherwise.
>>
>
> I don't know why Bonita dislikes spinning and sleeping, but I know why
> /I/ don't like it as a solution.  Sleeping does not affect thread
> priority in the way mutexes do.  That means if one low priority thread
> starts the initialisation and takes the lock, then gets pre-empted by a
> higher priority thread that tries to take the lock, your whole system
> can deadlock.  (The high priority thread may be sleeping, but there may
> be a mid-priority thread that can run and blocks the low-priority thread
> from running.)
>
> This is going to be a more likely failure situation if you have fewer
> (or only one) cores.  But the same compilers and toolchains are used for
> a wide variety of systems - you can't pick a solution that might fail on
> some systems.  And note that these kinds of failures never turn up in
> testing - they are rare, and only happen at the worst possible moment
> after deployment.
>
> This is particularly a risk for real-time systems and embedded systems,
> where you are more likely to have fewer cores (perhaps only one), or
> maybe some of your cores are dedicated to real-time tasks and
> unavailable for other threads.  You will also likely have high priority
> and real-time priority threads, which will block the low-priority
> threads.  And on such systems there might be very serious costs or
> safety risks involved in system hangs - you want to be sure that they
> are not possible, to the best of practical abilities, rather than
> designing in a solution that has a definite non-zero chance of failure.
>
> Using mutexes avoids this problem, because if a high priority thread is
> waiting on a mutex held by a low priority thread, the holder's priority
> gets boosted to that of the high priority thread until it releases the
> lock.
>
> Spinning should only be used when you have full control of the
> priorities of threads that may take the spin lock, and can be sure it is
> safe.
>
>

Sometimes adaptive mutexs are not the "right tool" for the job because
they can and will spin a couple of times, wrt their spin count.
Basically, use the right tool for your job at hand. Fair enough?

Re: Thread-safe initialization of static objects

<uei2p0$3l87c$4@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:41:36 -0700
Organization: A noiseless patient Spider
Lines: 125
Message-ID: <uei2p0$3l87c$4@dont-email.me>
References: <udafjf$2joeq$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> <20230917123203.524@kylheku.com>
<ue8lst$q25a$2@dont-email.me> <20230918101705.91@kylheku.com>
<uea1rj$1saml$1@dont-email.me> <hK5OM.30729$Yxl8.9621@fx14.iad>
<ueb3f7$2638l$2@dont-email.me> <z1MOM.13123$TwR4.1703@fx46.iad>
<uegt3a$3dj0r$4@dont-email.me>
<5f5de245-c174-4f2d-9870-6a990123b524n@googlegroups.com>
<ueh0rk$3ebkg$1@dont-email.me>
<3af7b0b8-cfca-47d7-82cf-0d2bd3b8b321n@googlegroups.com>
<ueh8s7$3gh0c$1@dont-email.me>
<bed7f83a-18a0-4b4a-bb8c-cb8ff4a72ab4n@googlegroups.com>
<ueheuu$3hkm3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Sep 2023 18:41:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3842284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185BuOozLjxT3HbXxvtMglBg8K1hHanUi4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:84jALXVbWrYXHI46fQ5xVI/UiAI=
Content-Language: en-US
In-Reply-To: <ueheuu$3hkm3$1@dont-email.me>
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:41 UTC

On 9/21/2023 6:03 AM, David Brown wrote:
> On 21/09/2023 14:01, Michael S wrote:
>> On Thursday, September 21, 2023 at 2:19:59 PM UTC+3, David Brown wrote:
>>> On 21/09/2023 11:59, Michael S wrote:
>>>> On Thursday, September 21, 2023 at 12:03:01 PM UTC+3, Bonita Montero
>>>> wrote:
>>>>> Am 21.09.2023 um 10:38 schrieb Michael S:
>>>>>
>>>>>> Actually, considering that contention is very rare in practice, ...
>>>>>
>>>>> The initialization might last an arbitrary time, so spinning
>>>>> is inacceptable.
>>>>
>>>> Why is it unacceptable? The impact of needless wake up of the
>>>> waiting thread
>>>> once per tick is negligible in terms of system performance and not too
>>>> horrible in terms power consumption. The impact of needless sleep
>>>> till the
>>>> next tick is also insignificant under assumption that initialization
>>>> took long time.
>>>>
>>>> I'd call it non-ideal when better solutions available, but perfectly
>>>> acceptable otherwise.
>>>>
>>> I don't know why Bonita dislikes spinning and sleeping, but I know why
>>> /I/ don't like it as a solution. Sleeping does not affect thread
>>> priority in the way mutexes do. That means if one low priority thread
>>> starts the initialisation and takes the lock, then gets pre-empted by a
>>> higher priority thread that tries to take the lock, your whole system
>>> can deadlock. (The high priority thread may be sleeping, but there may
>>> be a mid-priority thread that can run and blocks the low-priority thread
>>> from running.)
>>>
>>> This is going to be a more likely failure situation if you have fewer
>>> (or only one) cores. But the same compilers and toolchains are used for
>>> a wide variety of systems - you can't pick a solution that might fail on
>>> some systems. And note that these kinds of failures never turn up in
>>> testing - they are rare, and only happen at the worst possible moment
>>> after deployment.
>>>
>>> This is particularly a risk for real-time systems and embedded systems,
>>> where you are more likely to have fewer cores (perhaps only one), or
>>> maybe some of your cores are dedicated to real-time tasks and
>>> unavailable for other threads. You will also likely have high priority
>>> and real-time priority threads, which will block the low-priority
>>> threads. And on such systems there might be very serious costs or
>>> safety risks involved in system hangs - you want to be sure that they
>>> are not possible, to the best of practical abilities, rather than
>>> designing in a solution that has a definite non-zero chance of failure.
>>>
>>> Using mutexes avoids this problem, because if a high priority thread is
>>> waiting on a mutex held by a low priority thread, the holder's priority
>>> gets boosted to that of the high priority thread until it releases
>>> the lock.
>>>
>>> Spinning should only be used when you have full control of the
>>> priorities of threads that may take the spin lock, and can be sure it is
>>> safe.
>>
>> The problem you mention does not apply to general-purpose systems
>> like Windows, Linux, BSD-linage Unixes, Solaris e.t.c. They all have
>> built-in avoidance of deadlocks caused by priority-inversion. Most
>> commonly it's done by applying random priority boosts.
>
> As far as I know, such random priority boosts will not boost a
> non-realtime priority thread to real-time priority on Linux (and
> presumably not on other systems).  That would negate the whole concept
> of realtime priority threads.

Right, afaict, it seems to tend towards SCHED_OTHER. That is no good for
real time systems. Usually, pure wait-free algorithms are okay for real
time.

>
>>
>> Also I don't see how mutex semantics can possibly help. The common
>> problem scenario is that low-priority thread that is doing
>> initialization is
>> preempted when it *does not* hold the mutex. The mutex is held for
>> two very short durations of flags update. The preemption is far more
>> likely to happen during the middle phase - constructor itself.
>>
>> On real-time system with 1 or 2  processors you probably want
>> completely different design in which a mutex is held during all duration
>> of initialization, but you can't expect such solution to be included
>> in g++/clang++/MSVC compiler support libraries.
>>
>
> Yes, you would need the mutex to be held during critical stages of the
> initialisation.
>
> I can understand that this would be expensive compared to spinlocks that
> would work fine for "normal" systems (especially with the random boosts
> you described).  And I understand that toolchains have to be optimised
> for normal situations, not things that are extremely rare even in
> particular niche situations.
>
> But getting threading, locking and synchronisation details right is very
> difficult - most programmers don't get it right.  But you can't tell
> that you have a problem by testing the code, as failures typically
> require extreme bad luck in timing.  So it always worries me when I see
> something that is hidden, which most programmers will assume "just
> works, by some compiler magic", but which can be a problem in some
> circumstances.
>
> (As another example, gcc's "libatomic" uses spinlocks - if you use
> std::atomic types on a microcontroller in situations where atomics would
> be useful, they will hang your system any time there is a coincidental
> access.)
>
>> Which again brings us to the point made by myself  and few others:
>> don't do it! Don't use function-local static objects with constructors.
>> Or, at least don't use them in multitasking scenarios. Compiler's one
>> time initialization infrastructure can be super-robust, but being generic
>> it's unlikely to be optimal answer in any concrete scenario.
>>
>
> Yes, that is one option.  You can also use "constinit" statics safely.
> And gcc has a "-fno-threadsafe-statics" option (also useable as a
> pragma, but unfortunately not as a neater __attribute__) that puts the
> responsibility of ensuring things are threadsafe onto the user.
>
>
>

Re: Thread-safe initialization of static objects

<20230921114029.796@kylheku.com>

  copy mid

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

  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: Thu, 21 Sep 2023 18:42:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20230921114029.796@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<DUVOM.87557$noZ7.33800@fx13.iad> <uehdjj$3h8me$3@dont-email.me>
<uei1je$3l13h$3@dont-email.me>
Injection-Date: Thu, 21 Sep 2023 18:42:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d3d54e4b74191d06bda8ef3fd3367eb7";
logging-data="3844259"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19J9pLR6Y0RbXbBwXDC1Az9iLZIT5TiGtE="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:xEvGfESTSMmpWtGMLBonanjvSWE=
 by: Kaz Kylheku - Thu, 21 Sep 2023 18:42 UTC

On 2023-09-21, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
> On 9/21/2023 5:40 AM, Bonita Montero wrote:
>> Am 21.09.2023 um 13:36 schrieb Richard Damon:
>>
>>> Why?
>>
>> Because the initialization might only take a microsecond or less
>> and a yield is a full timeslice, on Linux and Windows usually one
>> millisecond.
>
> An adaptive backoff can be a mixture of the PAUSE instruction aka x86,
> and yield wrt the OS.

Ideally there shouldn't be a difference? In user mode execution, PAUSE
should be a privileged instruction. User space must not pause the
machine until an interrupt occurs. The privileged instruction will trap
to the kernel, where it becomes equivalent to a yield().

In the kernel, the lowest-priority idle task might execute that
instruction in a loop: the real one, not the trap.

When the scheduler determines there is truly nothing to do then it is
legitimate to dispatch an idle task which suspends the processor until
an external event.

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

<uei2su$3l13h$7@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:43:42 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <uei2su$3l13h$7@dont-email.me>
References: <udafjf$2joeq$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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<z1MOM.13123$TwR4.1703@fx46.iad> <uegt3a$3dj0r$4@dont-email.me>
<5f5de245-c174-4f2d-9870-6a990123b524n@googlegroups.com>
<ueh0rk$3ebkg$1@dont-email.me>
<3af7b0b8-cfca-47d7-82cf-0d2bd3b8b321n@googlegroups.com>
<ueh8s7$3gh0c$1@dont-email.me> <uehdf3$3h8me$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Sep 2023 18:43:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3834993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18b3ElHUD624aPJq1L25UgFq20AbZDLD7c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:Rof1/VrkcAmHTC53V4m1zyUgm5I=
In-Reply-To: <uehdf3$3h8me$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:43 UTC

On 9/21/2023 5:37 AM, Bonita Montero wrote:
> Am 21.09.2023 um 13:19 schrieb David Brown:
>
>> I don't know why Bonita dislikes spinning and sleeping, ...
>
> I only dislike spinning in userspace except when there's a
> limit to go for the slow path.

That's fine. For some reason I like to think of a spin is a slow path,
and a wait in the kernel is a "really" slow path! Fair enough? ;^)

> The thread holding a spinlock
> can be scheduled away an arbitrary time, that's unacceptable.

Re: Thread-safe initialization of static objects

<uei3kg$3l13h$8@dont-email.me>

  copy mid

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

  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: Thu, 21 Sep 2023 11:56:16 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <uei3kg$3l13h$8@dont-email.me>
References: <udafjf$2joeq$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> <20230917123203.524@kylheku.com>
<ue8lst$q25a$2@dont-email.me> <20230918101705.91@kylheku.com>
<uea1rj$1saml$1@dont-email.me> <hK5OM.30729$Yxl8.9621@fx14.iad>
<ueb3f7$2638l$2@dont-email.me> <z1MOM.13123$TwR4.1703@fx46.iad>
<uegt3a$3dj0r$4@dont-email.me>
<5f5de245-c174-4f2d-9870-6a990123b524n@googlegroups.com>
<ueh0rk$3ebkg$1@dont-email.me> <NQYOM.11221$%_f1.3150@fx06.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Sep 2023 18:56:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b6da6c06c8d4fdd39d62ecdcb8836b9";
logging-data="3834993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8UduQAjkyIXLQrHpch6HyiY7D68BVejA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:j8bkK3paL6JPdbG/VITh1yc4cXQ=
In-Reply-To: <NQYOM.11221$%_f1.3150@fx06.iad>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 21 Sep 2023 18:56 UTC

On 9/21/2023 7:56 AM, Scott Lurndal wrote:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>> Am 21.09.2023 um 10:38 schrieb Michael S:
>>
>>> Actually, considering that contention is very rare in practice, ...
>>
>> The initialization might last an arbitrary time, so spinning
>> is inacceptable.
>
> It's rare in practice because good programmers very seldom[*] use
> non-global static variables in threaded applications.
>
> [*] Effectively never.
>

Well, I concur with this. :^)

Re: Thread-safe initialization of static objects

<168b8330-93d1-43ca-a886-01a9bec8b2den@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:ac8:5a06:0:b0:417:9144:958c with SMTP id n6-20020ac85a06000000b004179144958cmr90409qta.4.1695332687310;
Thu, 21 Sep 2023 14:44:47 -0700 (PDT)
X-Received: by 2002:a05:6808:3992:b0:3ad:f3e6:6706 with SMTP id
gq18-20020a056808399200b003adf3e66706mr2653798oib.8.1695332687080; Thu, 21
Sep 2023 14:44:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.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: Thu, 21 Sep 2023 14:44:46 -0700 (PDT)
In-Reply-To: <uei0u9$3l0uh$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:f871:9f24:c014:651;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:f871:9f24:c014:651
References: <udafjf$2joeq$1@dont-email.me> <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> <20230917123203.524@kylheku.com>
<ue8lst$q25a$2@dont-email.me> <20230918101705.91@kylheku.com>
<uea1rj$1saml$1@dont-email.me> <hK5OM.30729$Yxl8.9621@fx14.iad>
<ueb3f7$2638l$2@dont-email.me> <z1MOM.13123$TwR4.1703@fx46.iad>
<uegt3a$3dj0r$4@dont-email.me> <5f5de245-c174-4f2d-9870-6a990123b524n@googlegroups.com>
<ueh0rk$3ebkg$1@dont-email.me> <3af7b0b8-cfca-47d7-82cf-0d2bd3b8b321n@googlegroups.com>
<ueh8s7$3gh0c$1@dont-email.me> <bed7f83a-18a0-4b4a-bb8c-cb8ff4a72ab4n@googlegroups.com>
<ueheuu$3hkm3$1@dont-email.me> <bbde3ce4-b969-431e-a3f6-d0b5ec6aafacn@googlegroups.com>
<uei0u9$3l0uh$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <168b8330-93d1-43ca-a886-01a9bec8b2den@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Thu, 21 Sep 2023 21:44:47 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2699
 by: Michael S - Thu, 21 Sep 2023 21:44 UTC

On Thursday, September 21, 2023 at 9:10:36 PM UTC+3, David Brown wrote:
>
> Looking at generated code (using godbolt.org) for Linux, it seems there
> is just a single byte boolean guard per object - there is no thread id
> or anything else stored per object. I don't know what is going on
> inside "__cxa_guard_acquire" and other such functions, however.

That's not what I see on x86-64.
I see size of guard object = 8 bytes. Both Windows and Linux, both
gcc and clang.

Re: Thread-safe initialization of static objects

<_X5PM.10143$hC28.7931@fx01.iad>

  copy mid

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

  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!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx01.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> <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> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<20230918110147.326@kylheku.com> <uea42g$1sn0e$2@dont-email.me>
<20230918123203.723@kylheku.com> <ueb3q5$2638l$5@dont-email.me>
<20230918205859.263@kylheku.com> <uebn7l$293m3$3@dont-email.me>
<20230919094617.529@kylheku.com> <uecn60$2f5ud$2@dont-email.me>
<20230919140127.732@kylheku.com> <uedpdo$2orvq$5@dont-email.me>
<20230919204410.51@kylheku.com> <uefhkh$3371r$1@dont-email.me>
<uegea8$3bfsj$3@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <uegea8$3bfsj$3@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 21
Message-ID: <_X5PM.10143$hC28.7931@fx01.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: Thu, 21 Sep 2023 21:18:50 -0400
X-Received-Bytes: 2699
 by: Richard Damon - Fri, 22 Sep 2023 01:18 UTC

On 9/20/23 11:46 PM, Bonita Montero wrote:
> Am 20.09.2023 um 21:36 schrieb Chris M. Thomasson:
>
>> A recursive lock would be interesting here...
>
> A recursive lock is impossible here since the object might have
> been partitially initialized and when coming back this partitial
> initialization would happen again.
>

If you get into a recursion of the SAME variable initialization, you
have a fundamental issue with your program design.

If to initialize variable A, you first have to have initialized that
same variable A, you have blocked yourself. Hanging in a Deadlock, or
aborting with a stack trace are reasonable responses. Since by the
defined behavior, the program has an essential deadlock, you can't
expect the system to find some magic to proceed around the problem. (I
don't think this triggers any Undefined Behavior to allow magic).

Re: Thread-safe initialization of static objects

<DS6PM.104552$GHI6.65122@fx17.iad>

  copy mid

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

  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!fx17.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@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> <20230917123203.524@kylheku.com>
<ue8lst$q25a$2@dont-email.me> <20230918101705.91@kylheku.com>
<uea1rj$1saml$1@dont-email.me> <hK5OM.30729$Yxl8.9621@fx14.iad>
<ueb3f7$2638l$2@dont-email.me> <z1MOM.13123$TwR4.1703@fx46.iad>
<uegt3a$3dj0r$4@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: <uegt3a$3dj0r$4@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 23
Message-ID: <DS6PM.104552$GHI6.65122@fx17.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 22 Sep 2023 02:21:23 UTC
Date: Thu, 21 Sep 2023 22:21:16 -0400
X-Received-Bytes: 2781
 by: Pavel - Fri, 22 Sep 2023 02:21 UTC

Bonita Montero wrote:

> This doesn't matter,
If this does not matter, why to mention it?

> because it's clear that static initialization
> can't work any other way than with a mutex. Yielding is inacceptable
> and spinlocking is inacceptable for reasons I've describet multiple
> times.
>
>> This is irrelevant to the discussion, but still is wrong:
>
> There's a non-initialized BSS segment with every executable and every
> shared library. This isn't physically part of the executable file but
> there's only a declared size to reserve. This block is initially com-
> pletely zero. This helps the C++ implementation since every static
> local object has initially an initialized-flag which is zero. This
> is stored along with the object itself.
How does the above prove your wrong point that initialization of static
synchronization primitives always may fail? It actually disproves this.
Whether using BSS or DATA segment (which depends on the requested
initial values), if the program is loaded successfully,
constant-initialized static variables are initialized without failure.

Re: Thread-safe initialization of static objects

<RW6PM.10144$hC28.451@fx01.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx01.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<z1MOM.13123$TwR4.1703@fx46.iad> <uegt3a$3dj0r$4@dont-email.me>
<uegtd7$3dolc$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: <uegtd7$3dolc$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 28
Message-ID: <RW6PM.10144$hC28.451@fx01.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 22 Sep 2023 02:25:53 UTC
Date: Thu, 21 Sep 2023 22:25:52 -0400
X-Received-Bytes: 2558
 by: Pavel - Fri, 22 Sep 2023 02:25 UTC

Bonita Montero wrote:
> Am 21.09.2023 um 09:58 schrieb Bonita Montero:
>
>>> They are only set to zero if they are not initialized explicitly.
>
>> I'm not talking about what the standad says but how it's implemented
>> with all operating systems that support virtual memory.
>
> This shows "all zero" on all modern operating systems:
>
> #include <iostream>
> #include <algorithm>
>
> using namespace std;
>
> int main()
> {
>     static char mem[0x1000000];
>     bool zero = find_if( mem, end( mem ), []( char c ) -> bool {
> return c; } ) == end( mem );
>     cout << (zero ? "all zero" : "has non-zero") << endl;
> }
What are you trying to prove? Your attempts on distraction are not
fooling anyone.

static pthread_once_t po = PTHERAD_ONCE_INIT;
will also be all zero. No possibility of runtime failure. No need to
change the standard.

Re: Thread-safe initialization of static objects

<ueiu42$3tima$1@dont-email.me>

  copy mid

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

  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: Fri, 22 Sep 2023 04:28:19 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ueiu42$3tima$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<ueggh5$3bq3f$1@dont-email.me> <uegsdo$3dj0r$1@dont-email.me>
<uei1g6$3l13h$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Sep 2023 02:28:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="667bcb529bd651b387f543a5d4231de5";
logging-data="4115146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pIVwzeWLxVJoGopN/yFr9iCFLM4pZpQY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:JcRXPdW2cuua6hTRGggplsCQX3s=
Content-Language: de-DE
In-Reply-To: <uei1g6$3l13h$2@dont-email.me>
 by: Bonita Montero - Fri, 22 Sep 2023 02:28 UTC

Am 21.09.2023 um 20:19 schrieb Chris M. Thomasson:

> On 9/21/2023 12:47 AM, Bonita Montero wrote:

>> We discussed yield with periodic polling.

> An adaptive backoff ...
Do you have ADHD ?
We discussed yield with periodic polling.

Re: Thread-safe initialization of static objects

<ueiu5b$3tima$2@dont-email.me>

  copy mid

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

  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: Fri, 22 Sep 2023 04:29:00 +0200
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <ueiu5b$3tima$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<DUVOM.87557$noZ7.33800@fx13.iad> <uehdjj$3h8me$3@dont-email.me>
<uehf2o$3hkm3$2@dont-email.me> <uehj9d$3idng$1@dont-email.me>
<uei1rg$3l13h$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Sep 2023 02:28:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="667bcb529bd651b387f543a5d4231de5";
logging-data="4115146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Zurbxp6XFdvPUhaCvodLphSy2gKgdzt4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:+S5kruWG8dsv9Q/wr/l/iwvZkMk=
In-Reply-To: <uei1rg$3l13h$4@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Fri, 22 Sep 2023 02:29 UTC

Am 21.09.2023 um 20:25 schrieb Chris M. Thomasson:
> On 9/21/2023 7:17 AM, Bonita Montero wrote:
>> Am 21.09.2023 um 15:05 schrieb David Brown:
>>
>>> "Yield" won't take a timeslice unless there is something else of the
>>> same priority, waiting to run on the same core. ...
>>
>> Ok, you're right, but the code would be still unacceptable under load.
>>
>
> Wait, are you talking about a _pure_ spin lock in user space here?
> For some reason you seem to be struggling with adaptive backoffs, ...

No, we were discussing yielding.

Re: Thread-safe initialization of static objects

<ueiu6e$3tima$3@dont-email.me>

  copy mid

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

  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: Fri, 22 Sep 2023 04:29:35 +0200
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <ueiu6e$3tima$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<DUVOM.87557$noZ7.33800@fx13.iad> <uehdjj$3h8me$3@dont-email.me>
<uei1je$3l13h$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Sep 2023 02:29:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="667bcb529bd651b387f543a5d4231de5";
logging-data="4115146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TOYw+BuEiNmNGdA1i9Vpug/qjVu+Gh+E="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qWCv2RnlggnVISVOSwkaFHihlu8=
Content-Language: de-DE
In-Reply-To: <uei1je$3l13h$3@dont-email.me>
 by: Bonita Montero - Fri, 22 Sep 2023 02:29 UTC

Am 21.09.2023 um 20:21 schrieb Chris M. Thomasson:
> On 9/21/2023 5:40 AM, Bonita Montero wrote:
>> Am 21.09.2023 um 13:36 schrieb Richard Damon:
>>
>>> Why?
>>
>> Because the initialization might only take a microsecond or less
>> and a yield is a full timeslice, on Linux and Windows usually one
>> millisecond.
>
> An adaptive backoff can be a mixture of the PAUSE instruction aka x86,
> and yield wrt the OS.

Do you have a mental disorder ?
We were discussing yielding.

Re: Thread-safe initialization of static objects

<ueiu87$3tima$4@dont-email.me>

  copy mid

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

  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: Fri, 22 Sep 2023 04:30:32 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <ueiu87$3tima$4@dont-email.me>
References: <udafjf$2joeq$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> <20230917123203.524@kylheku.com>
<ue8lst$q25a$2@dont-email.me> <20230918101705.91@kylheku.com>
<uea1rj$1saml$1@dont-email.me> <hK5OM.30729$Yxl8.9621@fx14.iad>
<ueb3f7$2638l$2@dont-email.me> <z1MOM.13123$TwR4.1703@fx46.iad>
<uegt3a$3dj0r$4@dont-email.me>
<5f5de245-c174-4f2d-9870-6a990123b524n@googlegroups.com>
<ueh0rk$3ebkg$1@dont-email.me> <uei2ji$3l87c$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 22 Sep 2023 02:30:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="667bcb529bd651b387f543a5d4231de5";
logging-data="4115146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/K1EQh5yHaqC5y4/xWAtibT2VhsRamBMg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:PuNRWQ57lG4TP7LTSFnRcr52dV8=
Content-Language: de-DE
In-Reply-To: <uei2ji$3l87c$2@dont-email.me>
 by: Bonita Montero - Fri, 22 Sep 2023 02:30 UTC

Am 21.09.2023 um 20:38 schrieb Chris M. Thomasson:
> On 9/21/2023 2:02 AM, Bonita Montero wrote:
>> Am 21.09.2023 um 10:38 schrieb Michael S:
>>
>>> Actually, considering that contention is very rare in practice, ...
>>
>> The initialization might last an arbitrary time, so spinning
>> is inacceptable.
>>
>>> So even use of Futex | Critical Section | SRW lock,  although it make
>>> a lot of sense in practice,  is not necessary from theoretical P.O.V.
>>
>> Why should a SRW-lock make sense here ? If the object isn't initialized
>> iz can't be read meanwhile. And a futex isn't a replacement for a mutex
>> but just a faster slow path for a mutex.
>>
>>
>>
>
> A futex can be used to build a mutex, semaphore, a condition variable,
> ect... A futex is a nice building block that works out pretty damn good.

We were disussing SRW-locks, how they're implemented doesn't matter here.

> Have a lock-free algorithm that you want to make block on certain
> conditions, build a predicate and we can use it with a futex.

Re: Thread-safe initialization of static objects

<ueiuar$3tima$5@dont-email.me>

  copy mid

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

  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: Fri, 22 Sep 2023 04:31:56 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ueiuar$3tima$5@dont-email.me>
References: <udafjf$2joeq$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>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<z1MOM.13123$TwR4.1703@fx46.iad> <uegt3a$3dj0r$4@dont-email.me>
<DS6PM.104552$GHI6.65122@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Sep 2023 02:31:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="667bcb529bd651b387f543a5d4231de5";
logging-data="4115146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sgkGugDpY+oWp+hoTk46QOYPL5SSzMqM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7qmZmBcKMMYsFblcWfOBFDTKztY=
In-Reply-To: <DS6PM.104552$GHI6.65122@fx17.iad>
Content-Language: de-DE
 by: Bonita Montero - Fri, 22 Sep 2023 02:31 UTC

Am 22.09.2023 um 04:21 schrieb Pavel:

> How does the above prove your wrong point that initialization of static
> synchronization primitives always may fail? ...

The mutex is created along with the static object from zeroed memory
whene there's contention. At least this may fail. And with Windows
the synchronization may also fail.

Re: Thread-safe initialization of static objects

<ueiucq$3tima$6@dont-email.me>

  copy mid

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

  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: Fri, 22 Sep 2023 04:32:59 +0200
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <ueiucq$3tima$6@dont-email.me>
References: <udafjf$2joeq$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>
<ue7r4j$i3u1$1@dont-email.me> <ue8mid$q534$2@dont-email.me>
<O9XNM.16067$JX2f.12159@fx13.iad> <20230918110147.326@kylheku.com>
<uea42g$1sn0e$2@dont-email.me> <20230918123203.723@kylheku.com>
<ueb3q5$2638l$5@dont-email.me> <20230918205859.263@kylheku.com>
<uebn7l$293m3$3@dont-email.me> <20230919094617.529@kylheku.com>
<uecn60$2f5ud$2@dont-email.me> <20230919140127.732@kylheku.com>
<uedpdo$2orvq$5@dont-email.me> <20230919204410.51@kylheku.com>
<uefhkh$3371r$1@dont-email.me> <uegea8$3bfsj$3@dont-email.me>
<ueggj7$3bq3f$2@dont-email.me> <uegsls$3dj0r$3@dont-email.me>
<uei2cc$3l87c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Sep 2023 02:32:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="667bcb529bd651b387f543a5d4231de5";
logging-data="4115146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NVL0OQiUejDEn0XZee6dmCVkY0DGlx8c="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ySpF0NLSz0KeVF6gHl8AZkJAYUs=
Content-Language: de-DE
In-Reply-To: <uei2cc$3l87c$1@dont-email.me>
 by: Bonita Montero - Fri, 22 Sep 2023 02:32 UTC

Am 21.09.2023 um 20:34 schrieb Chris M. Thomasson:
> On 9/21/2023 12:51 AM, Bonita Montero wrote:
>> Am 21.09.2023 um 06:25 schrieb Chris M. Thomasson:
>>> On 9/20/2023 8:46 PM, Bonita Montero wrote:
>>
>>>> Am 20.09.2023 um 21:36 schrieb Chris M. Thomasson:
>>
>>>> A recursive lock is impossible here since the object might have
>>>> been partitially initialized and when coming back this partitial
>>>> initialization would happen again.
>>
>>> A recursive would only provide a, so of, false sense of security wrt
>>> the infinite recursion that is present in the user code.
>>
>> A recursive lock wouldn't make sense here since the object might have
>> beein partitially created when it re-enters the mutex which guards the
>> initialization.
>>
>
> Huh? I must be misunderstanding you here. A Recursive mutex means it
> allows the same thread to acquire it more than once. It can be detected
> rather easily.

It's not about how recursion may be detected here but that any kind
of recursion doesn't make sense here.

Re: Thread-safe initialization of static objects

<ueiudq$3tima$7@dont-email.me>

  copy mid

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

  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: Fri, 22 Sep 2023 04:33:31 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <ueiudq$3tima$7@dont-email.me>
References: <udafjf$2joeq$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>
<ue7r4j$i3u1$1@dont-email.me> <ue8mid$q534$2@dont-email.me>
<O9XNM.16067$JX2f.12159@fx13.iad> <20230918110147.326@kylheku.com>
<uea42g$1sn0e$2@dont-email.me> <20230918123203.723@kylheku.com>
<ueb3q5$2638l$5@dont-email.me> <20230918205859.263@kylheku.com>
<uebn7l$293m3$3@dont-email.me> <20230919094617.529@kylheku.com>
<uecn60$2f5ud$2@dont-email.me> <20230919140127.732@kylheku.com>
<uedpdo$2orvq$5@dont-email.me> <20230919204410.51@kylheku.com>
<uefhkh$3371r$1@dont-email.me> <uegea8$3bfsj$3@dont-email.me>
<_X5PM.10143$hC28.7931@fx01.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Sep 2023 02:33:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="667bcb529bd651b387f543a5d4231de5";
logging-data="4115146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190rkdL7QwJvt+4gcjjU2bGiMDpeNFOtPU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Ixe3QGVVatVCHwlN2+Jmery9AaM=
Content-Language: de-DE
In-Reply-To: <_X5PM.10143$hC28.7931@fx01.iad>
 by: Bonita Montero - Fri, 22 Sep 2023 02:33 UTC

Am 22.09.2023 um 03:18 schrieb Richard Damon:

> If you get into a recursion of the SAME variable initialization, you
> have a fundamental issue with your program design.

That's what I said.

Re: Thread-safe initialization of static objects

<th7PM.6493$wGe2.6301@fx03.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx03.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
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> <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> <aJINM.23275$H8td.10140@fx10.iad>
<ue8lv5$q25a$3@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: <ue8lv5$q25a$3@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 14
Message-ID: <th7PM.6493$wGe2.6301@fx03.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 22 Sep 2023 02:50:01 UTC
Date: Thu, 21 Sep 2023 22:50:01 -0400
X-Received-Bytes: 2451
 by: Pavel - Fri, 22 Sep 2023 02:50 UTC

Bonita Montero wrote:
> Am 17.09.2023 um 21:47 schrieb Richard Damon:
>
>> Why does it need to take into account that an BAD implementation might
>> fail.
>
> With the deferred initialization of a C++ mutex the mutex
> could fail on synchronization even without being bad.
A "deferred" initialization of a static sync primitive used to sync
static initialization of a C++ object is not only unnecessary (constant
initialization is enough) but also would be useless if used. Because how
would you correctly synchronize this "deferred" initialization itself if
the initialization of the static object is requested concurrently from 2
threads. You should stop invent and talk nonsense.

Re: Thread-safe initialization of static objects

<fp7PM.104556$GHI6.80009@fx17.iad>

  copy mid

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

  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!fx17.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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> <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>
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: <uegsia$3dj0r$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 17
Message-ID: <fp7PM.104556$GHI6.80009@fx17.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 22 Sep 2023 02:58:19 UTC
Date: Thu, 21 Sep 2023 22:58:18 -0400
X-Received-Bytes: 2554
 by: Pavel - Fri, 22 Sep 2023 02:58 UTC

Bonita Montero wrote:
> Am 21.09.2023 um 02:42 schrieb Pavel:
>
>> Then there are lots of these on prevalent platforms that either cannot
>> fail ...
>
> The standard shoudln't mandate such platform capabilities.
It **is** the job of the standard authors to assume what elementary
operations can and what cannot fail and build their specs upon that.
They may do it more or less successfully. In this case, *at least* the
modern prevalent platforms (whereas modern means those that were alive
by the time C++ 11 was adopted or appeared soon after) have the
syncroniztion primitives that can be created and locked without a
failure. In fact, you failed to point out a single platform where such
capabilities are absent. Hence the standard authors did a very good job
in this particular regard and there is nothing to change in this regard.
Plain and simple.


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

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor