Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

If it wasn't for Newton, we wouldn't have to eat bruised apples.


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

<uf29r4$3afmc$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.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: Wed, 27 Sep 2023 15:20:20 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <uf29r4$3afmc$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 22:20:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3489484"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+icnTthz0HN+rGYsIDYN/fP2sPLmyvQ2U="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:WA9IpJ+FN5iwZZlXZAoWaF/rlWA=
Content-Language: en-US
In-Reply-To: <00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 22:20 UTC

On 9/27/2023 2:48 PM, Michael S wrote:
> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
>>> 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.
>> The slow path always is backed by a binary semaphore of the kernel.
>> You can't create an arbitrary number of that.
>
> Today I tested how Critical Sections and Exclusive SRW locks are implemented
> on various versions Windows (x86-64).
>
> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
> does not create kernel objects. Kernel object is created on first wait, if there were
> waits. And indeed there is 1 kernel object per critical section that waited until once
> and was not explicitly deleted after that.
>
> Critical sections on Ws2016 never create kernel objects. It does not matter if they
> were ever waited on or not.
> I didn't test on win10, but its essentially the same kernel as
> Ws2016, so I expect the same behavior with very high certainty.
>
> Exclusive SRW locks never create kernel objects as well, on any variant of
> Windows OS, but that was already obvious from the absence of destruction
> method in the API.
>
>
>
>

I need to examine the kernel for nt4 again:

https://github.com/ZoloZiak/WinNT4/tree/master/private/ntos

Re: Thread-safe initialization of static objects

<31e3bb97-39fc-4541-92da-e4088679d436n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:90b:b0:65b:c47:10dc with SMTP id dj11-20020a056214090b00b0065b0c4710dcmr79536qvb.3.1695853504085;
Wed, 27 Sep 2023 15:25:04 -0700 (PDT)
X-Received: by 2002:a05:6808:1a0e:b0:3a8:74ff:6c01 with SMTP id
bk14-20020a0568081a0e00b003a874ff6c01mr1427779oib.5.1695853503911; Wed, 27
Sep 2023 15:25:03 -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: Wed, 27 Sep 2023 15:25:03 -0700 (PDT)
In-Reply-To: <uf29h6$3afmc$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:d42d:131b:1419:df4e;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:d42d:131b:1419:df4e
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com> <uf29h6$3afmc$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <31e3bb97-39fc-4541-92da-e4088679d436n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Wed, 27 Sep 2023 22:25:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3996
 by: Michael S - Wed, 27 Sep 2023 22:25 UTC

On Thursday, September 28, 2023 at 1:15:22 AM UTC+3, Chris M. Thomasson wrote:
> On 9/27/2023 2:48 PM, Michael S wrote:
> > On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
> >> Am 26.09.2023 um 13:23 schrieb Richard Damon:
> >>> 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.
> >> The slow path always is backed by a binary semaphore of the kernel.
> >> You can't create an arbitrary number of that.
> >
> > Today I tested how Critical Sections and Exclusive SRW locks are implemented
> > on various versions Windows (x86-64).
> >
> > Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
> > does not create kernel objects. Kernel object is created on first wait, if there were
> > waits. And indeed there is 1 kernel object per critical section that waited until once
> > and was not explicitly deleted after that.
> I cannot remember kernel keyed events were implemented in win7, I am
> pretty sure they were. Have you ever messed around with those before?

I have no idea what the phrase "kernel keyed events" means.

> >
> > Critical sections on Ws2016 never create kernel objects. It does not matter if they
> > were ever waited on or not.
> > I didn't test on win10, but its essentially the same kernel as
> > Ws2016, so I expect the same behavior with very high certainty.
> >
> > Exclusive SRW locks never create kernel objects as well, on any variant of
> > Windows OS, but that was already obvious from the absence of destruction
> > method in the API.
> >
> >
> >
> >

Re: Thread-safe initialization of static objects

<20230927152604.508@kylheku.com>

  copy mid

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

  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: Wed, 27 Sep 2023 22:27:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <20230927152604.508@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
Injection-Date: Wed, 27 Sep 2023 22:27:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9b3f31f8706362ec3eacce961c3d2318";
logging-data="3494205"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hY0vdzQIsZNJxyu64KRJs/0KwrIl0rPY="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:L/KaWV/TDE6H7aQViyHRt2D5PBE=
 by: Kaz Kylheku - Wed, 27 Sep 2023 22:27 UTC

On 2023-09-27, Michael S <already5chosen@yahoo.com> wrote:
> Critical sections on Ws2016 never create kernel objects. It does not matter if they
> were ever waited on or not.
> I didn't test on win10, but its essentially the same kernel as
> Ws2016, so I expect the same behavior with very high certainty.

Could this in any way be related to Microsoft evidently obtaining a patent on
futexes in 2014?

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

<M82RM.53538$2_m.14475@fx38.iad>

  copy mid

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

  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!fx38.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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> <3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me> <00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com> <uf29r4$3afmc$2@dont-email.me>
Lines: 37
Message-ID: <M82RM.53538$2_m.14475@fx38.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 27 Sep 2023 22:37:32 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 27 Sep 2023 22:37:32 GMT
X-Received-Bytes: 2648
 by: Scott Lurndal - Wed, 27 Sep 2023 22:37 UTC

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>On 9/27/2023 2:48 PM, Michael S wrote:
>> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
>>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
>>>> 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.
>>> The slow path always is backed by a binary semaphore of the kernel.
>>> You can't create an arbitrary number of that.
>>
>> Today I tested how Critical Sections and Exclusive SRW locks are implemented
>> on various versions Windows (x86-64).
>>
>> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
>> does not create kernel objects. Kernel object is created on first wait, if there were
>> waits. And indeed there is 1 kernel object per critical section that waited until once
>> and was not explicitly deleted after that.
>>
>> Critical sections on Ws2016 never create kernel objects. It does not matter if they
>> were ever waited on or not.
>> I didn't test on win10, but its essentially the same kernel as
>> Ws2016, so I expect the same behavior with very high certainty.
>>
>> Exclusive SRW locks never create kernel objects as well, on any variant of
>> Windows OS, but that was already obvious from the absence of destruction
>> method in the API.
>>
>>
>>
>>
>
>I need to examine the kernel for nt4 again:
>
>https://github.com/ZoloZiak/WinNT4/tree/master/private/ntos

Why? It's a quarter century old. Did it even support threads?

Re: Thread-safe initialization of static objects

<uf2bhu$3arar$1@dont-email.me>

  copy mid

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

  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: Wed, 27 Sep 2023 15:49:34 -0700
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <uf2bhu$3arar$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<uf29r4$3afmc$2@dont-email.me> <M82RM.53538$2_m.14475@fx38.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 22:49:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3501403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mjzrNIoCW/6Sro5XGDWZwESK/cfkmVII="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:SEboweQ8povNwCEedBMqc9fC6zQ=
Content-Language: en-US
In-Reply-To: <M82RM.53538$2_m.14475@fx38.iad>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 22:49 UTC

On 9/27/2023 3:37 PM, Scott Lurndal wrote:
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>> On 9/27/2023 2:48 PM, Michael S wrote:
>>> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
>>>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
>>>>> 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.
>>>> The slow path always is backed by a binary semaphore of the kernel.
>>>> You can't create an arbitrary number of that.
>>>
>>> Today I tested how Critical Sections and Exclusive SRW locks are implemented
>>> on various versions Windows (x86-64).
>>>
>>> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
>>> does not create kernel objects. Kernel object is created on first wait, if there were
>>> waits. And indeed there is 1 kernel object per critical section that waited until once
>>> and was not explicitly deleted after that.
>>>
>>> Critical sections on Ws2016 never create kernel objects. It does not matter if they
>>> were ever waited on or not.
>>> I didn't test on win10, but its essentially the same kernel as
>>> Ws2016, so I expect the same behavior with very high certainty.
>>>
>>> Exclusive SRW locks never create kernel objects as well, on any variant of
>>> Windows OS, but that was already obvious from the absence of destruction
>>> method in the API.
>>>
>>>
>>>
>>>
>>
>> I need to examine the kernel for nt4 again:
>>
>> https://github.com/ZoloZiak/WinNT4/tree/master/private/ntos
>
> Why? It's a quarter century old. Did it even support threads?
>

NT 4? Yup, it supported threads.

Re: Thread-safe initialization of static objects

<uf2bve$3arar$2@dont-email.me>

  copy mid

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

  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: Wed, 27 Sep 2023 15:56:45 -0700
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <uf2bve$3arar$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<uf29h6$3afmc$1@dont-email.me>
<31e3bb97-39fc-4541-92da-e4088679d436n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 22:56:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3501403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iwl02yb7jgbB/rxroySQmv4Ll7aK9xv4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:6K5U/HHBL3vNfmIL5S655GJUVtU=
In-Reply-To: <31e3bb97-39fc-4541-92da-e4088679d436n@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 27 Sep 2023 22:56 UTC

On 9/27/2023 3:25 PM, Michael S wrote:
> On Thursday, September 28, 2023 at 1:15:22 AM UTC+3, Chris M. Thomasson wrote:
>> On 9/27/2023 2:48 PM, Michael S wrote:
>>> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
>>>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
>>>>> 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.
>>>> The slow path always is backed by a binary semaphore of the kernel.
>>>> You can't create an arbitrary number of that.
>>>
>>> Today I tested how Critical Sections and Exclusive SRW locks are implemented
>>> on various versions Windows (x86-64).
>>>
>>> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
>>> does not create kernel objects. Kernel object is created on first wait, if there were
>>> waits. And indeed there is 1 kernel object per critical section that waited until once
>>> and was not explicitly deleted after that.
>> I cannot remember kernel keyed events were implemented in win7, I am
>> pretty sure they were. Have you ever messed around with those before?
>
> I have no idea what the phrase "kernel keyed events" means.

There is a sync object in windows called a keyed event, however I think
its only for the kernel. Iirc, I learned about it in a sysinternals
magazine. Forgot the issue number. It is a special type of Windows Event
object.

>
>>>
>>> Critical sections on Ws2016 never create kernel objects. It does not matter if they
>>> were ever waited on or not.
>>> I didn't test on win10, but its essentially the same kernel as
>>> Ws2016, so I expect the same behavior with very high certainty.
>>>
>>> Exclusive SRW locks never create kernel objects as well, on any variant of
>>> Windows OS, but that was already obvious from the absence of destruction
>>> method in the API.
>>>
>>>
>>>
>>>

Re: Thread-safe initialization of static objects

<uf2c02$3arar$3@dont-email.me>

  copy mid

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

  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: Wed, 27 Sep 2023 15:57:06 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <uf2c02$3arar$3@dont-email.me>
References: <udafjf$2joeq$1@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> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<20230927152604.508@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 22:57:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3501403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/r+7WhKqhQGzJ4jQKsYTswvi7ec9UrT7c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:k8kKN0lfpqwwO9YplNw2p4Ctx4c=
In-Reply-To: <20230927152604.508@kylheku.com>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 27 Sep 2023 22:57 UTC

On 9/27/2023 3:27 PM, Kaz Kylheku wrote:
> On 2023-09-27, Michael S <already5chosen@yahoo.com> wrote:
>> Critical sections on Ws2016 never create kernel objects. It does not matter if they
>> were ever waited on or not.
>> I didn't test on win10, but its essentially the same kernel as
>> Ws2016, so I expect the same behavior with very high certainty.
>
> Could this in any way be related to Microsoft evidently obtaining a patent on
> futexes in 2014?
>

NO SHIT!!! ;^o wow.!

Re: Thread-safe initialization of static objects

<a8ac344c-2ce4-4905-9d41-ddba36b526a6n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:ac8:5dcb:0:b0:412:1bc3:10f3 with SMTP id e11-20020ac85dcb000000b004121bc310f3mr37068qtx.13.1695855599598;
Wed, 27 Sep 2023 15:59:59 -0700 (PDT)
X-Received: by 2002:a05:6870:9885:b0:1dd:1837:c704 with SMTP id
eg5-20020a056870988500b001dd1837c704mr1122586oab.2.1695855599303; Wed, 27 Sep
2023 15:59:59 -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: Wed, 27 Sep 2023 15:59:58 -0700 (PDT)
In-Reply-To: <M82RM.53538$2_m.14475@fx38.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:d42d:131b:1419:df4e;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:d42d:131b:1419:df4e
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com> <uf29r4$3afmc$2@dont-email.me>
<M82RM.53538$2_m.14475@fx38.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a8ac344c-2ce4-4905-9d41-ddba36b526a6n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Wed, 27 Sep 2023 22:59:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3683
 by: Michael S - Wed, 27 Sep 2023 22:59 UTC

On Thursday, September 28, 2023 at 1:37:48 AM UTC+3, Scott Lurndal wrote:
> "Chris M. Thomasson" <chris.m.t...@gmail.com> writes:
> >On 9/27/2023 2:48 PM, Michael S wrote:
> >> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
> >>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
> >>>> 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.
> >>> The slow path always is backed by a binary semaphore of the kernel.
> >>> You can't create an arbitrary number of that.
> >>
> >> Today I tested how Critical Sections and Exclusive SRW locks are implemented
> >> on various versions Windows (x86-64).
> >>
> >> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
> >> does not create kernel objects. Kernel object is created on first wait, if there were
> >> waits. And indeed there is 1 kernel object per critical section that waited until once
> >> and was not explicitly deleted after that.
> >>
> >> Critical sections on Ws2016 never create kernel objects. It does not matter if they
> >> were ever waited on or not.
> >> I didn't test on win10, but its essentially the same kernel as
> >> Ws2016, so I expect the same behavior with very high certainty.
> >>
> >> Exclusive SRW locks never create kernel objects as well, on any variant of
> >> Windows OS, but that was already obvious from the absence of destruction
> >> method in the API.
> >>
> >>
> >>
> >>
> >
> >I need to examine the kernel for nt4 again:
> >
> >https://github.com/ZoloZiak/WinNT4/tree/master/private/ntos
> Why? It's a quarter century old. Did it even support threads?

Windows Nt supports threads since its very first version, non-intuitively
named 3.1. I.e. 30 years.

Re: Thread-safe initialization of static objects

<uf2ch7$3arar$4@dont-email.me>

  copy mid

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

  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: Wed, 27 Sep 2023 16:06:14 -0700
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <uf2ch7$3arar$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<uf29r4$3afmc$2@dont-email.me> <M82RM.53538$2_m.14475@fx38.iad>
<a8ac344c-2ce4-4905-9d41-ddba36b526a6n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 23:06:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3501403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eQJKfV9PdA3QQimFihKvxBz/7zhSFDOo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:HurCTLJb4HrTIIArDoRepXmFaGc=
Content-Language: en-US
In-Reply-To: <a8ac344c-2ce4-4905-9d41-ddba36b526a6n@googlegroups.com>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 23:06 UTC

On 9/27/2023 3:59 PM, Michael S wrote:
> On Thursday, September 28, 2023 at 1:37:48 AM UTC+3, Scott Lurndal wrote:
>> "Chris M. Thomasson" <chris.m.t...@gmail.com> writes:
>>> On 9/27/2023 2:48 PM, Michael S wrote:
>>>> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
>>>>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
>>>>>> 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.
>>>>> The slow path always is backed by a binary semaphore of the kernel.
>>>>> You can't create an arbitrary number of that.
>>>>
>>>> Today I tested how Critical Sections and Exclusive SRW locks are implemented
>>>> on various versions Windows (x86-64).
>>>>
>>>> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
>>>> does not create kernel objects. Kernel object is created on first wait, if there were
>>>> waits. And indeed there is 1 kernel object per critical section that waited until once
>>>> and was not explicitly deleted after that.
>>>>
>>>> Critical sections on Ws2016 never create kernel objects. It does not matter if they
>>>> were ever waited on or not.
>>>> I didn't test on win10, but its essentially the same kernel as
>>>> Ws2016, so I expect the same behavior with very high certainty.
>>>>
>>>> Exclusive SRW locks never create kernel objects as well, on any variant of
>>>> Windows OS, but that was already obvious from the absence of destruction
>>>> method in the API.
>>>>
>>>>
>>>>
>>>>
>>>
>>> I need to examine the kernel for nt4 again:
>>>
>>> https://github.com/ZoloZiak/WinNT4/tree/master/private/ntos
>> Why? It's a quarter century old. Did it even support threads?
>
> Windows Nt supports threads since its very first version,

Yup. You are correct. Windows NT 4 even had IOCP.

> non-intuitively named 3.1. I.e. 30 years.

Re: Thread-safe initialization of static objects

<df41705c-32cc-4730-81d4-b5f7571be4dbn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:a66:b0:65a:f49b:3e70 with SMTP id ef6-20020a0562140a6600b0065af49b3e70mr38073qvb.5.1695856208705;
Wed, 27 Sep 2023 16:10:08 -0700 (PDT)
X-Received: by 2002:a05:6808:30a1:b0:3a8:43ed:ce9c with SMTP id
bl33-20020a05680830a100b003a843edce9cmr1281160oib.1.1695856208151; Wed, 27
Sep 2023 16:10:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.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: Wed, 27 Sep 2023 16:10:07 -0700 (PDT)
In-Reply-To: <uf2ch7$3arar$4@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:d42d:131b:1419:df4e;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:d42d:131b:1419:df4e
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com> <uf29r4$3afmc$2@dont-email.me>
<M82RM.53538$2_m.14475@fx38.iad> <a8ac344c-2ce4-4905-9d41-ddba36b526a6n@googlegroups.com>
<uf2ch7$3arar$4@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <df41705c-32cc-4730-81d4-b5f7571be4dbn@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Wed, 27 Sep 2023 23:10:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Michael S - Wed, 27 Sep 2023 23:10 UTC

On Thursday, September 28, 2023 at 2:06:33 AM UTC+3, Chris M. Thomasson wrote:
> On 9/27/2023 3:59 PM, Michael S wrote:
> > On Thursday, September 28, 2023 at 1:37:48 AM UTC+3, Scott Lurndal wrote:
> >> "Chris M. Thomasson" <chris.m.t...@gmail.com> writes:
> >>> On 9/27/2023 2:48 PM, Michael S wrote:
> >>>> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
> >>>>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
> >>>>>> 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.
> >>>>> The slow path always is backed by a binary semaphore of the kernel.
> >>>>> You can't create an arbitrary number of that.
> >>>>
> >>>> Today I tested how Critical Sections and Exclusive SRW locks are implemented
> >>>> on various versions Windows (x86-64).
> >>>>
> >>>> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
> >>>> does not create kernel objects. Kernel object is created on first wait, if there were
> >>>> waits. And indeed there is 1 kernel object per critical section that waited until once
> >>>> and was not explicitly deleted after that.
> >>>>
> >>>> Critical sections on Ws2016 never create kernel objects. It does not matter if they
> >>>> were ever waited on or not.
> >>>> I didn't test on win10, but its essentially the same kernel as
> >>>> Ws2016, so I expect the same behavior with very high certainty.
> >>>>
> >>>> Exclusive SRW locks never create kernel objects as well, on any variant of
> >>>> Windows OS, but that was already obvious from the absence of destruction
> >>>> method in the API.
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>> I need to examine the kernel for nt4 again:
> >>>
> >>> https://github.com/ZoloZiak/WinNT4/tree/master/private/ntos
> >> Why? It's a quarter century old. Did it even support threads?
> >
> > Windows Nt supports threads since its very first version,
> Yup. You are correct. Windows NT 4 even had IOCP.

Didn't IOCP come earlier? Nt 3.5?

> > non-intuitively named 3.1. I.e. 30 years.

Re: Thread-safe initialization of static objects

<uf2d2t$3arar$5@dont-email.me>

  copy mid

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

  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: Wed, 27 Sep 2023 16:15:41 -0700
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <uf2d2t$3arar$5@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<uf29r4$3afmc$2@dont-email.me> <M82RM.53538$2_m.14475@fx38.iad>
<a8ac344c-2ce4-4905-9d41-ddba36b526a6n@googlegroups.com>
<uf2ch7$3arar$4@dont-email.me>
<df41705c-32cc-4730-81d4-b5f7571be4dbn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 23:15:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3501403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uFDBMFbMJBD7hilDgFNOo/dnNUycA3FA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:Ps5AoQ73bWvHPoYkCHGgYHVybf8=
Content-Language: en-US
In-Reply-To: <df41705c-32cc-4730-81d4-b5f7571be4dbn@googlegroups.com>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 23:15 UTC

On 9/27/2023 4:10 PM, Michael S wrote:
> On Thursday, September 28, 2023 at 2:06:33 AM UTC+3, Chris M. Thomasson wrote:
>> On 9/27/2023 3:59 PM, Michael S wrote:
>>> On Thursday, September 28, 2023 at 1:37:48 AM UTC+3, Scott Lurndal wrote:
>>>> "Chris M. Thomasson" <chris.m.t...@gmail.com> writes:
>>>>> On 9/27/2023 2:48 PM, Michael S wrote:
>>>>>> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
>>>>>>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
>>>>>>>> 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.
>>>>>>> The slow path always is backed by a binary semaphore of the kernel.
>>>>>>> You can't create an arbitrary number of that.
>>>>>>
>>>>>> Today I tested how Critical Sections and Exclusive SRW locks are implemented
>>>>>> on various versions Windows (x86-64).
>>>>>>
>>>>>> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
>>>>>> does not create kernel objects. Kernel object is created on first wait, if there were
>>>>>> waits. And indeed there is 1 kernel object per critical section that waited until once
>>>>>> and was not explicitly deleted after that.
>>>>>>
>>>>>> Critical sections on Ws2016 never create kernel objects. It does not matter if they
>>>>>> were ever waited on or not.
>>>>>> I didn't test on win10, but its essentially the same kernel as
>>>>>> Ws2016, so I expect the same behavior with very high certainty.
>>>>>>
>>>>>> Exclusive SRW locks never create kernel objects as well, on any variant of
>>>>>> Windows OS, but that was already obvious from the absence of destruction
>>>>>> method in the API.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> I need to examine the kernel for nt4 again:
>>>>>
>>>>> https://github.com/ZoloZiak/WinNT4/tree/master/private/ntos
>>>> Why? It's a quarter century old. Did it even support threads?
>>>
>>> Windows Nt supports threads since its very first version,
>> Yup. You are correct. Windows NT 4 even had IOCP.
>
> Didn't IOCP come earlier? Nt 3.5?

Good question. I cannot remember right now! I used it a lot in NT 4.
Shit, your question kind of got me here. I cannot remember right now.
Anyway, thanks for the brain sparks, Michael!

>
>>> non-intuitively named 3.1. I.e. 30 years.

Re: Thread-safe initialization of static objects

<04671fd3-7fdb-4e66-8a76-36c84df81f9dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:181a:b0:411:fe24:ab9d with SMTP id t26-20020a05622a181a00b00411fe24ab9dmr107697qtc.3.1695857913353;
Wed, 27 Sep 2023 16:38:33 -0700 (PDT)
X-Received: by 2002:a05:6870:b7a6:b0:1dd:39ce:e258 with SMTP id
ed38-20020a056870b7a600b001dd39cee258mr1270279oab.4.1695857913082; Wed, 27
Sep 2023 16:38:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!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: Wed, 27 Sep 2023 16:38:32 -0700 (PDT)
In-Reply-To: <20230927152604.508@kylheku.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:d42d:131b:1419:df4e;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:d42d:131b:1419:df4e
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com> <20230927152604.508@kylheku.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <04671fd3-7fdb-4e66-8a76-36c84df81f9dn@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Wed, 27 Sep 2023 23:38:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3426
 by: Michael S - Wed, 27 Sep 2023 23:38 UTC

On Thursday, September 28, 2023 at 1:27:57 AM UTC+3, Kaz Kylheku wrote:
> On 2023-09-27, Michael S <already...@yahoo.com> wrote:
> > Critical sections on Ws2016 never create kernel objects. It does not matter if they
> > were ever waited on or not.
> > I didn't test on win10, but its essentially the same kernel as
> > Ws2016, so I expect the same behavior with very high certainty.
> Could this in any way be related to Microsoft evidently obtaining a patent on
> futexes in 2014?
> --

It's not all roses.
According to my preliminary measurements when the thread is blocked on
Critical Section or on Exclusive SRW lock, Ws2016 scheduler is an order of
magnitude slower than Ws2008 in granting the core to another ready thread.

At least, that's what happens when both threads are manually assigned to the
same core by SetThreadAffinityMask(). May be, in less artificial situations
it's not that bad, I didn't figure out yet how to test that.

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

Re: Thread-safe initialization of static objects

<d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:50e:b0:418:1ae1:bc37 with SMTP id l14-20020a05622a050e00b004181ae1bc37mr9583qtx.3.1695899242284;
Thu, 28 Sep 2023 04:07:22 -0700 (PDT)
X-Received: by 2002:a05:6808:1997:b0:3ad:f6ad:b9c8 with SMTP id
bj23-20020a056808199700b003adf6adb9c8mr353846oib.9.1695899242053; Thu, 28 Sep
2023 04:07:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.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: Thu, 28 Sep 2023 04:07:21 -0700 (PDT)
In-Reply-To: <00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
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> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Thu, 28 Sep 2023 11:07:22 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Michael S - Thu, 28 Sep 2023 11:07 UTC

On Thursday, September 28, 2023 at 12:48:42 AM UTC+3, Michael S wrote:
> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
> > Am 26.09.2023 um 13:23 schrieb Richard Damon:
> > > 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.
> > The slow path always is backed by a binary semaphore of the kernel.
> > You can't create an arbitrary number of that.
>
> Today I tested how Critical Sections and Exclusive SRW locks are implemented
> on various versions Windows (x86-64).
>
> Critical sections on Win7/Ws2008 implemented as you guessed it - initialization
> does not create kernel objects. Kernel object is created on first wait, if there were
> waits. And indeed there is 1 kernel object per critical section that waited until once
> and was not explicitly deleted after that.

Under further exploration it turned out somewhat less simple.
1 kernel object per critical section that ever waited is true up to slightly
less than 16M kernel objects. The number of kernel objects stops to grow after
that, but critical sections continue to work as expected and slow path does not
become observably slower. So, it seems, the infrastructure for sharing of one
kernel object per multiple Critical Section instances already exists in pre-10
Windows. But it is triggered at very different point.

However now I am certain that huge number of Critical Sections [that waited] is
supported just fine on Win7/Ws2008. I tried 200,000,000 critical sections, that's
8 GB for critical sections storage alone. It works flawlessly.

So, even on this old variant of Windows OS Bonita is wrong - lock() method of
non-shared mutex can't fail due to deficit of kernel objects.

>
> Critical sections on Ws2016 never create kernel objects. It does not matter if they
> were ever waited on or not.
> I didn't test on win10, but its essentially the same kernel as
> Ws2016, so I expect the same behavior with very high certainty.
>
> Exclusive SRW locks never create kernel objects as well, on any variant of
> Windows OS, but that was already obvious from the absence of destruction
> method in the API.

Re: Thread-safe initialization of static objects

<uf3npo$3li66$1@dont-email.me>

  copy mid

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

  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: Thu, 28 Sep 2023 13:24:42 +0200
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <uf3npo$3li66$1@dont-email.me>
References: <udafjf$2joeq$1@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> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 28 Sep 2023 11:24:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6463b9f567f139c5f92561439fee313e";
logging-data="3852486"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MIyh8lM2O7+hJyZmL4U9GftDX37NWQyQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:FOWGE1Oi2qAWpztHxwpMXtLZGSs=
In-Reply-To: <d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com>
Content-Language: de-DE
 by: Bonita Montero - Thu, 28 Sep 2023 11:24 UTC

Am 28.09.2023 um 13:07 schrieb Michael S:

> Under further exploration it turned out somewhat less simple.
> 1 kernel object per critical section that ever waited is true up to slightly
> less than 16M kernel objects. The number of kernel objects stops to grow after
> that, but critical sections continue to work as expected and slow path does not
> become observably slower. ...
Show me your code.

Re: Thread-safe initialization of static objects

<3d9a2d52-5a7d-4a6f-b4a6-1aa98feba2e7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:ad4:59cf:0:b0:656:2ff6:c592 with SMTP id el15-20020ad459cf000000b006562ff6c592mr11506qvb.8.1695901601554;
Thu, 28 Sep 2023 04:46:41 -0700 (PDT)
X-Received: by 2002:a05:6870:c784:b0:1cc:6948:d83a with SMTP id
dy4-20020a056870c78400b001cc6948d83amr411140oab.1.1695901601332; Thu, 28 Sep
2023 04:46:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Thu, 28 Sep 2023 04:46:40 -0700 (PDT)
In-Reply-To: <uf3npo$3li66$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <udafjf$2joeq$1@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> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com> <uf3npo$3li66$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3d9a2d52-5a7d-4a6f-b4a6-1aa98feba2e7n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Thu, 28 Sep 2023 11:46:41 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 14
 by: Michael S - Thu, 28 Sep 2023 11:46 UTC

On Thursday, September 28, 2023 at 2:25:01 PM UTC+3, Bonita Montero wrote:
> Am 28.09.2023 um 13:07 schrieb Michael S:
>
> > Under further exploration it turned out somewhat less simple.
> > 1 kernel object per critical section that ever waited is true up to slightly
> > less than 16M kernel objects. The number of kernel objects stops to grow after
> > that, but critical sections continue to work as expected and slow path does not
> > become observably slower. ...
> Show me your code.

I can, but you wouldn't understand.

Re: Thread-safe initialization of static objects

<uf3siu$3me1l$1@dont-email.me>

  copy mid

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

  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: Thu, 28 Sep 2023 14:46:23 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uf3siu$3me1l$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com>
<uf3npo$3li66$1@dont-email.me>
<3d9a2d52-5a7d-4a6f-b4a6-1aa98feba2e7n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 28 Sep 2023 12:46:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6463b9f567f139c5f92561439fee313e";
logging-data="3881013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+04bzrgVVGF6IDhiwzsvBmObse3ZMrJK8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:g18ajpmYG7cs7Ku35XW0DnFAEUw=
In-Reply-To: <3d9a2d52-5a7d-4a6f-b4a6-1aa98feba2e7n@googlegroups.com>
Content-Language: de-DE
 by: Bonita Montero - Thu, 28 Sep 2023 12:46 UTC

Am 28.09.2023 um 13:46 schrieb Michael S:

> I can, but you wouldn't understand.

Of course I would understand that. But I'm aware of the 2 ^ 24 handle
per process limit and I'm asking myself how it would be possible to
have so much mutex-associated handles as well as at least half the
number of threads, which are associated with a handle also. I guess
you never investigated that.

Re: Thread-safe initialization of static objects

<0642f3cf-6f95-4257-9198-7ea927513e78n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:57c9:b0:64a:4269:c91a with SMTP id lw9-20020a05621457c900b0064a4269c91amr14121qvb.6.1695906574908;
Thu, 28 Sep 2023 06:09:34 -0700 (PDT)
X-Received: by 2002:a9d:7dcc:0:b0:6b9:a955:43bc with SMTP id
k12-20020a9d7dcc000000b006b9a95543bcmr266429otn.3.1695906574615; Thu, 28 Sep
2023 06:09:34 -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, 28 Sep 2023 06:09:34 -0700 (PDT)
In-Reply-To: <uf3siu$3me1l$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com> <d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com>
<uf3npo$3li66$1@dont-email.me> <3d9a2d52-5a7d-4a6f-b4a6-1aa98feba2e7n@googlegroups.com>
<uf3siu$3me1l$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0642f3cf-6f95-4257-9198-7ea927513e78n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Thu, 28 Sep 2023 13:09:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2706
 by: Michael S - Thu, 28 Sep 2023 13:09 UTC

On Thursday, September 28, 2023 at 3:46:43 PM UTC+3, Bonita Montero wrote:
> Am 28.09.2023 um 13:46 schrieb Michael S:
>
> > I can, but you wouldn't understand.
> Of course I would understand that. But I'm aware of the 2 ^ 24 handle
> per process limit and I'm asking myself how it would be possible to
> have so much mutex-associated handles as well as at least half the
> number of threads, which are associated with a handle also. I guess
> you never investigated that.

I'll store my code on github later today. Around 21:00 UTC.

Re: Thread-safe initialization of static objects

<0362fb54-0227-4cd2-8676-419a34c8fdb4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:192c:b0:63f:c0b9:e08a with SMTP id es12-20020a056214192c00b0063fc0b9e08amr28999qvb.4.1695936848360;
Thu, 28 Sep 2023 14:34:08 -0700 (PDT)
X-Received: by 2002:a05:6808:2219:b0:3ac:ab4f:ef3 with SMTP id
bd25-20020a056808221900b003acab4f0ef3mr1169237oib.6.1695936848140; Thu, 28
Sep 2023 14:34:08 -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: Thu, 28 Sep 2023 14:34:07 -0700 (PDT)
In-Reply-To: <uf3siu$3me1l$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:b85f:f9ca:a2bd:dd27;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:b85f:f9ca:a2bd:dd27
References: <udafjf$2joeq$1@dont-email.me> <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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com> <d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com>
<uf3npo$3li66$1@dont-email.me> <3d9a2d52-5a7d-4a6f-b4a6-1aa98feba2e7n@googlegroups.com>
<uf3siu$3me1l$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0362fb54-0227-4cd2-8676-419a34c8fdb4n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Thu, 28 Sep 2023 21:34:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2883
 by: Michael S - Thu, 28 Sep 2023 21:34 UTC

On Thursday, September 28, 2023 at 3:46:43 PM UTC+3, Bonita Montero wrote:
> Am 28.09.2023 um 13:46 schrieb Michael S:
>
> > I can, but you wouldn't understand.
> Of course I would understand that.

https://github.com/already5chosen/others/tree/master/win_mutex_tests

> But I'm aware of the 2 ^ 24 handle
> per process limit and I'm asking myself how it would be possible to
> have so much mutex-associated handles as well as at least half the
> number of threads, which are associated with a handle also. I guess
> you never investigated that.

My tests use small # of threads (3), but can wait, sequentially, on lots
of critical sections.

Re: Thread-safe initialization of static objects

<AhpRM.327525$ZXz4.22293@fx18.iad>

  copy mid

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

  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!fx18.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@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> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<uf29ag$3aeta$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.1
MIME-Version: 1.0
In-Reply-To: <uf29ag$3aeta$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 52
Message-ID: <AhpRM.327525$ZXz4.22293@fx18.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 29 Sep 2023 00:57:04 UTC
Date: Thu, 28 Sep 2023 20:56:56 -0400
X-Received-Bytes: 3683
 by: Pavel - Fri, 29 Sep 2023 00:56 UTC

Chris M. Thomasson wrote:
> On 9/27/2023 2:48 PM, Michael S wrote:
>> On Tuesday, September 26, 2023 at 3:37:35 PM UTC+3, Bonita Montero wrote:
>>> Am 26.09.2023 um 13:23 schrieb Richard Damon:
>>>> 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.
>>> The slow path always is backed by a binary semaphore of the kernel.
>>> You can't create an arbitrary number of that.
>>
>> Today I tested how Critical Sections and Exclusive SRW locks are
>> implemented
>> on various versions Windows (x86-64).
>>
>> Critical sections on Win7/Ws2008 implemented as you guessed it -
>> initialization
>> does not create kernel objects. Kernel object is created on first
>> wait, if there were
>> waits. And indeed there is 1 kernel object per critical section that
>> waited until once
>> and was not explicitly deleted after that.
>
> Well, shit happens. Yuck.
2008 is before 2012; hence the requirement for infallible
synchronization for C++ static initialization did not exist back then,
at least not officially. When the new standard appeared, Microsoft
implemented better sync. primitives.

That's what I already wrote somewhere above: it's not the standard that
needs to honor platform limitations; it's the platforms that will honor
a reasonable spec of the standard (or leave unfulfilled the unreasonable
one). Obviously, infallible sync for static init is not unreasonable at all.

>
>
>>
>> Critical sections on Ws2016 never create kernel objects. It does not
>> matter if they
>> were ever waited on or not.
>> I didn't test on win10, but its essentially the same kernel as
>> Ws2016, so I expect the same behavior with very high certainty.
>>
>> Exclusive SRW locks never create kernel objects as well, on any
>> variant of
>> Windows OS, but that was already obvious from the absence of destruction
>> method in the API.
>>
>>
>>
>>
>

Re: Thread-safe initialization of static objects

<SDpRM.53616$wO91.39551@fx39.iad>

  copy mid

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

  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!fx39.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
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>
<20230926094053.617@kylheku.com> <uev2c6$2je12$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.1
MIME-Version: 1.0
In-Reply-To: <uev2c6$2je12$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 56
Message-ID: <SDpRM.53616$wO91.39551@fx39.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 29 Sep 2023 01:20:50 UTC
Date: Thu, 28 Sep 2023 21:20:50 -0400
X-Received-Bytes: 4542
 by: Pavel - Fri, 29 Sep 2023 01:20 UTC

Bonita Montero wrote:
> Am 26.09.2023 um 18:46 schrieb Kaz Kylheku:
>
>> You probably don't choose a platform where mutexes require resources
>> that are only allocated on lock contention, and which can then blow up.
>
> Contention is always possible and always expensive.
>
>> Memory overcommit is enabled on most GNU/Linux system installations.
>> This means that memory allocations can fail not when you allocate
>> the memory (e.g. mmap() returning MAP_FAILED or malloc returning null)
>> but when you try to access the memory.
>
> Memory overcommit partitially bases on swappable memory. Seamphores are
> in non-pageable memory inside the kernel. But I accept what you mean: if
> you accept that an application can suddenly terminate because of the OOM
> killer you also might accept that it would be terminated because a sin-
> gle kernel semaphore coudn't be created. That may be acceptable for most
> users but if there's an error code from the kernel this still should be
> forwarded through your runtime for those who coudln't accept that.
>
I thought you were already shown that memory allocation or commit is
not necessary for static initialization synchronization in some earlier
post by Kaz Kylheku that you apparently did not want to understand.

Maybe the below will be more clear.

You can have a static user-space word (like a futex) and a per-thread
double-linked entry with a pointer that points to that user-space word
if the thread "slow-waits" for lock on that user-space futex.

Pointers to all such links can be collected to a single hashtable (of
size of the number of threads slow-waiting for mutex) where the hash
function is computed from the address of the user-space word and the
equivalence is the equality of that address. The hash entries are only
added or removed when threads are created and destroyed.

This way, the kernel space needed for "slow-waiting" is a constant x the
number of threads; hence this space does not need to be allocated other
than when the thread is created (and NOT when a synchronization
primitive is initialized or locked).

For static C++ initialization, the user-space words are
constant-initialized static ints or whatever other integral type is used
so they all are allocated at program loading time. Hence, this cannot
fail either.

To summarize, no kernel or user-space resource need to be allocated in
for either initializing or locking the synchronization primitive (which,
for C++ static var initialization purpose, will likely not be a mutex
but call-once control entirely fit in that single user-space word; but a
mutex can also work in the same infallible way just in case you wondered).

Therefore, locking does not have to be fallible for kernel resource
allocation purpose and C++ standard is good as it is in this regard.

Re: Thread-safe initialization of static objects

<pFpRM.53617$wO91.13324@fx39.iad>

  copy mid

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

  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!fx39.iad.POSTED!not-for-mail
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>
<TQqQM.164532$1B%c.109462@fx09.iad> <uetl3q$2bd8t$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.1
MIME-Version: 1.0
In-Reply-To: <uetl3q$2bd8t$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 32
Message-ID: <pFpRM.53617$wO91.13324@fx39.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 29 Sep 2023 01:22:29 UTC
Date: Thu, 28 Sep 2023 21:22:29 -0400
X-Received-Bytes: 2865
 by: Pavel - Fri, 29 Sep 2023 01:22 UTC

Chris M. Thomasson wrote:
> 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?
>
> :^)
Sure it does. Thanks!

Re: Thread-safe initialization of static objects

<uf59c4$3ul6i$1@dont-email.me>

  copy mid

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

  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, 28 Sep 2023 18:30:43 -0700
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <uf59c4$3ul6i$1@dont-email.me>
References: <udafjf$2joeq$1@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> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me>
<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
<d1fc9003-673c-4d7b-ad17-d37a75c39bd3n@googlegroups.com>
<uf3npo$3li66$1@dont-email.me>
<3d9a2d52-5a7d-4a6f-b4a6-1aa98feba2e7n@googlegroups.com>
<uf3siu$3me1l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 29 Sep 2023 01:30:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="20313435b82470e1f6eec4f85dde8931";
logging-data="4150482"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Zslb5RJozJUP/hBW3Ns2XcK56KADMNgg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:9mAbW+qjdmYGe6VxRhVf3NfMTaA=
Content-Language: en-US
In-Reply-To: <uf3siu$3me1l$1@dont-email.me>
 by: Chris M. Thomasson - Fri, 29 Sep 2023 01:30 UTC

On 9/28/2023 5:46 AM, Bonita Montero wrote:
> Am 28.09.2023 um 13:46 schrieb Michael S:
>
>> I can, but you wouldn't understand.
>
> Of course I would understand that. But I'm aware of the 2 ^ 24 handle
> per process limit and I'm asking myself how it would be possible to
> have so much mutex-associated handles as well as at least half the
> number of threads, which are associated with a handle also. I guess
> you never investigated that.
>

Humm, perhaps the test should contain 16^16 threads? You need to study up.

Re: Thread-safe initialization of static objects

<uf59r7$3unn6$1@dont-email.me>

  copy mid

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

  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, 28 Sep 2023 18:38:47 -0700
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <uf59r7$3unn6$1@dont-email.me>
References: <udafjf$2joeq$1@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> <20230926094053.617@kylheku.com>
<uev2c6$2je12$1@dont-email.me> <SDpRM.53616$wO91.39551@fx39.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 29 Sep 2023 01:38:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="20313435b82470e1f6eec4f85dde8931";
logging-data="4153062"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jnh0bSb8daP+OLe9+AZLmW0zT30vt3Y4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:Op7u8Nfi1xY56DpKDDj9K03YZGQ=
Content-Language: en-US
In-Reply-To: <SDpRM.53616$wO91.39551@fx39.iad>
 by: Chris M. Thomasson - Fri, 29 Sep 2023 01:38 UTC

On 9/28/2023 6:20 PM, Pavel wrote:
> Bonita Montero wrote:
>> Am 26.09.2023 um 18:46 schrieb Kaz Kylheku:
>>
>>> You probably don't choose a platform where mutexes require resources
>>> that are only allocated on lock contention, and which can then blow up.
>>
>> Contention is always possible and always expensive.
>>
>>> Memory overcommit is enabled on most GNU/Linux system installations.
>>> This means that memory allocations can fail not when you allocate
>>> the memory (e.g. mmap() returning MAP_FAILED or malloc returning null)
>>> but when you try to access the memory.
>>
>> Memory overcommit partitially bases on swappable memory. Seamphores are
>> in non-pageable memory inside the kernel. But I accept what you mean: if
>> you accept that an application can suddenly terminate because of the OOM
>> killer you also might accept that it would be terminated because a sin-
>> gle kernel semaphore coudn't be created. That may be acceptable for most
>> users but if there's an error code from the kernel this still should be
>> forwarded through your runtime for those who coudln't accept that.
>>
> I thought you were already shown that memory allocation or commit  is
> not necessary for static initialization synchronization in some earlier
> post by Kaz Kylheku that you apparently did not want to understand.
>
> Maybe the below will be more clear.
>
> You can have a static user-space word (like a futex) and a per-thread
> double-linked entry with a pointer that points to that user-space word
> if the thread "slow-waits" for lock on that user-space futex.
>
> Pointers to all such links can be collected to a single hashtable (of
> size of the number of threads slow-waiting for mutex) where the hash
> function is computed from the address of the user-space word and the
> equivalence is the equality of that address. The hash entries are only
> added or removed when threads are created and destroyed.
>
> This way, the kernel space needed for "slow-waiting" is a constant x the
> number of threads; hence this space does not need to be allocated other
> than when the thread is created (and NOT when a synchronization
> primitive is initialized or locked).
>
> For static C++ initialization, the user-space words are
> constant-initialized static ints or whatever other integral type is used
> so they all are allocated at program loading time. Hence, this cannot
> fail either.
>
> To summarize, no kernel or user-space resource need to be allocated in
> for either initializing or locking the synchronization primitive (which,
> for C++ static var initialization purpose, will likely not be a mutex
> but call-once control entirely fit in that single user-space word; but a
> mutex can also work in the same infallible way just in case you wondered).
>
> Therefore, locking does not have to be fallible for kernel resource
> allocation purpose and C++ standard is good as it is in this regard.
>

I have a feeling that Bonita will not understand 99.999...% of this and
call you some sort of insulting name, or something. ;^)

Re: Thread-safe initialization of static objects

<OUpRM.268847$2ph4.41670@fx14.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!rocksolid2!i2pn.org!paganini.bofh.team!2.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
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>
<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> <ueu52o$2dv5f$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.1
MIME-Version: 1.0
In-Reply-To: <ueu52o$2dv5f$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 29
Message-ID: <OUpRM.268847$2ph4.41670@fx14.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 29 Sep 2023 01:38:54 UTC
Date: Thu, 28 Sep 2023 21:38:53 -0400
X-Received-Bytes: 3048
 by: Pavel - Fri, 29 Sep 2023 01:38 UTC

Bonita Montero wrote:
> 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.
What? throwing? -- Not if those *some* C++ mutex types are not needed to
implement C++ static var initialization and non-throwing and faster type
is available.

>
>> 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.
>
So far you have not pointed to such a platform that would appear or stay
current and non-supporting after C++11 spec release.

As I said before, C++ implementations on platforms should and do try to
honor reasonable standard specs, not the other way around. This way the
platform try to distinguish themselves and attract more apps and then
others have to follow. This is called "progress". Catering to
least-common-denominator never worked (but, in this particular case,
nobody even referred to a platform that can't comply so adding
fallibility to static initialization (and breaking tons of old code at
that) wouldn't even be anyhow justified).

Re: Thread-safe initialization of static objects

<4WpRM.268869$2ph4.65476@fx14.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@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>
<ueu52o$2dv5f$1@dont-email.me> <1tzQM.252985$2ph4.238002@fx14.iad>
<ueuj3l$2gdqk$1@dont-email.me> <8KCQM.35601$ugs.6585@fx36.iad>
<ueutfg$2ihvn$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.1
MIME-Version: 1.0
In-Reply-To: <ueutfg$2ihvn$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 9
Message-ID: <4WpRM.268869$2ph4.65476@fx14.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 29 Sep 2023 01:40:16 UTC
Date: Thu, 28 Sep 2023 21:40:16 -0400
X-Received-Bytes: 1660
 by: Pavel - Fri, 29 Sep 2023 01:40 UTC

Bonita Montero wrote:
> Am 26.09.2023 um 17:25 schrieb Scott Lurndal:
>
>> No, there is no delayed initialization with pthread mutexes.
>
> There must be since you can't create a semaphore by pure assignment.
>
See mine or earlier Kaz's explanations above for how you actually can do
it (and how, iirc, it is done on Linux).


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

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor