Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

MAC user's dynamic debugging list evaluator? Never heard of that.


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

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

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

<uevdl0$2ligo$4@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 13:06:55 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <uevdl0$2ligo$4@dont-email.me>
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>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 20:06:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2804248"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/N5KyzgOOv1EcBxkxgQt6YKuno1SGJl30="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:omezwlHi3zy208Cy29HxEEoKkwI=
Content-Language: en-US
In-Reply-To: <ueuj9u$2gdqk$3@dont-email.me>
 by: Chris M. Thomasson - Tue, 26 Sep 2023 20:06 UTC

On 9/26/2023 5:37 AM, 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.

Barf! God damn it Bonita! I might have to try to refrain from reading
your posts. PUKE!

Re: Thread-safe initialization of static objects

<uevdmb$2ligo$5@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 13:07:38 -0700
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <uevdmb$2ligo$5@dont-email.me>
References: <udafjf$2joeq$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> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Sep 2023 20:07:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2804248"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dEv72vVOKLtRpggnOwMorZaoOmift87g="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:TS47IhaBh/bbJ5/CwDMkinuIlAo=
Content-Language: en-US
In-Reply-To: <ueutjo$2ii89$2@dont-email.me>
 by: Chris M. Thomasson - Tue, 26 Sep 2023 20:07 UTC

On 9/26/2023 8:33 AM, Bonita Montero wrote:
> Am 26.09.2023 um 17:24 schrieb Scott Lurndal:
>
>> No, it is not.   The kernel simply moves the waiter thread to
>> a non-runnable queue in the dispatcher until a call to 'unlock'
>> determines that there is a waiter and tells the kernel to
>> awaken it.
>
> The userspace code must tell the kernel what it its waiting for.
> Mutexes are always a combination of an atomic for the fast path
> and a binary semapohre for the slow path.
>

Word salad that you do not even understand. Sorry buddy.

Re: Thread-safe initialization of static objects

<ueveg4$2ligo$6@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 13:21:23 -0700
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <ueveg4$2ligo$6@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>
<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>
<20230926095933.402@kylheku.com> <BiEQM.286107$%uv8.162186@fx15.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 20:21:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2804248"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185ajsdKIY6vnGUz70txAC7Fu03/fnzu5A="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:7RbDjEME/EgN8Aa1kwC6Y7ZqeR4=
Content-Language: en-US
In-Reply-To: <BiEQM.286107$%uv8.162186@fx15.iad>
 by: Chris M. Thomasson - Tue, 26 Sep 2023 20:21 UTC

On 9/26/2023 10:13 AM, Scott Lurndal wrote:
> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>> On 2023-09-26, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> Am 26.09.2023 um 13:42 schrieb Richard Damon:
>>>
>>>> Again, your argument boils down to: Even though there is a way to do
>>>> it without failure, the fact that another, "defective" way exists that
>>>> might generate an error, the Standard should be modified so that
>>>> "defective" method can be used.
>>>
>>> Pthread mutexes can be initialized statically, but then you have the
>>> same kind of delayed inititialization - which may fail.
>>
>> It has already been explained that none of the error codes given in
>> POSIX for the pthread_mutex_lock function have anything to do with
>> resource acquisition.
>
> Although it is fair to point out that POSIX allows additional
> implementation-defined error codes for POSIX interfaces, so long
> as the listed conditions return the listed error codes.
>
> That's not meant to imply that posix mutexes will ever fail, however.

Good point. :^)

Re: Thread-safe initialization of static objects

<5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:1820:b0:417:9205:acc8 with SMTP id t32-20020a05622a182000b004179205acc8mr85927qtc.6.1695761938438;
Tue, 26 Sep 2023 13:58:58 -0700 (PDT)
X-Received: by 2002:a05:6808:30a8:b0:3ae:21ca:9b74 with SMTP id
bl40-20020a05680830a800b003ae21ca9b74mr76137oib.1.1695761938237; Tue, 26 Sep
2023 13:58:58 -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: Tue, 26 Sep 2023 13:58:57 -0700 (PDT)
In-Reply-To: <uevd5n$2ligo$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.182.115; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.182.115
References: <udafjf$2joeq$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <20230924092501.340@kylheku.com>
<uetrjn$2car5$1@dont-email.me> <e01f389c-3f23-47dc-89cd-a21038c6592an@googlegroups.com>
<uevd5n$2ligo$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Tue, 26 Sep 2023 20:58:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 8204
 by: Michael S - Tue, 26 Sep 2023 20:58 UTC

On Tuesday, September 26, 2023 at 10:59:06 PM UTC+3, Chris M. Thomasson wrote:
> On 9/26/2023 9:05 AM, Michael S wrote:
> > On Tuesday, September 26, 2023 at 8:53:13 AM UTC+3, Chris M. Thomasson wrote:
> >> On 9/24/2023 10:04 AM, Kaz Kylheku wrote:
> >>> On 2023-09-24, Bonita Montero <Bonita....@gmail.com> wrote:
> >>>> Am 24.09.2023 um 04:22 schrieb Kaz Kylheku:
> >>>>
> >>>>> A possible design is that each *thread* has a wait semaphore.
> >>>>
> >>>> You'd have to register the binary semaphore and register as a waiter in
> >>>> one atomic step. You could do that with a DCAS'd ring, but you coudn't
> >>>> atomically update the link pointers of the other nodes at the same
> >>>> time you update the roots link pointers. And you would have the deallo-
> >>>> cation poblem, i.e. the memory of your object may never be deallocated.
> >>>
> >>> Now you're just throwing together words you don't understand.
> >>>
> >>>> Show me your implementation !
> >>>
> >>> E.g. old LinuxThreads in glibc, circa 2000:
> >>>
> >>> https://sourceware.org/git/?p=glibc.git;a=blob;f=linuxthreads/spinlock.c;h=5cd772602c8858edd8238e73eefcbf2758935d74;hb=d82e4c7bb231c9e0f835bd46467563ac3b56cebe
> >>>
> >>> The low level __pthread_lock and __pthread_unlock functions maintain a
> >>> queue, using a single-word atomic CAS.
> >>>
> >>> There are suspend() and resume() functions for the waiting;
> >>> they are elsewhere.
> >>>
> >>> If you look in restart.h you can see that those operations are defined
> >>> in two different ways, both of which use signals (not a semaphore per
> >>> thread). A suspending thread waits for the arrival of a signal,
> >>> resume is done by sending a signal. That's kind of semaphore-like;
> >>> and POSIX real-time signals can even queue up, like a counting sem.
> >>>
> >>>> It's ridiculous because mutex are a cheap resource. And if such imple-
> >>>> mentation would be possible the standard shouldn't mandate it since
> >>>> not every platform has a DCAS.
> >>>
> >>> Things can be done in ways you havn't thought about.
> >>>
> >>> Atomic operations aren't required to achieve mutual exclusion among
> >>> processors that share memory.
> >>>
> >>> As someone continually insisting on having expertise in concurrency,
> >>> you must be familiar with the research work of Leslie Lamport?
> >>
> >> Iirc, that uses atomic loads, stores and membars. Iirc, it requires a
> >> #StoreLoad barrier on the SPARC. Iirc, it even requires an explicit
> >> membar on the x86. MFENCE, or XCHG which has the lock prefix
> >> automatically asserted. Humm... There is a way to get around that
> >> bastard #StoreLoad membar... It uses an async sync setup. The funny
> >> thing is that Windows has a API that can be used to actually implement
> >> it! Try to think of a so called, remote memory barrier, in a sense:
> >>
> >> https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushprocesswritebuffers
> >>
> >> There is a way to use this to get an async mutex that is kind of sort of
> >> akin to a read write mutex. Basically, the mutex is broken down into two
> >> parts. One that represents accesses that _very_ frequently called upon..
> >> The other one is used rather rarely. This is the async nature that can
> >> be exploited in rather interesting ways. I implemented some in the past
> >> with Dmitry Vyukov. Also, this FlushProcessWriteBuffers API can be used
> >> to implement other rather exotic sync schemes. They have very excellent
> >> performance for certain workloads. Actually, there is a way to use it to
> >> get a RCU in userspace and/or hazard pointers without any explicit
> >> #StoreLoad membars.
> >>
> >>
> >
> > I would expect FlushProcessWriteBuffers() to be 2 orders of magnitude
> > slower than #StoreLoad membar. I could be wrong, of course, the function
> > is close to undocumented.
> FlushProcessWriteBuffers() can be used to gain a quiescent state wrt
> memory visibility for some exotic async algorithms, it is called in
> certain places and is RARE. However, on the other hand, having to use a
> #StoreLoad membar on the fast path is not good. Keep in mind that this
> is meant to handle a store followed by a load to another location
> scenario. We need to honor the #StoreLoad relationship for this type of
> setup for these types of algorithms. For instance, hazard pointers
> require a #StoreLoad, however there is a way to eliminate them using
> some special magic wrt RCU...
>
> My friend Joe Seigh created SMR+RCU to gain this. SMR is hazard
> pointers. Now, keep in mind that these are very "specialized" algorithms
> that try to make certain workloads MUCH faster and way more efficient.
> They work for that.
>
> Also, keep in mind that a normal mutex does not require #StoreLoad. Only
> acquire and release:
>
> acquire = #LoadStore | #LoadLoad
> release = #LoadStore | #StoreStore
>
> In SPARC parlance. For instance, an atomic store on x86 automatically
> implies release. Btw, have you ever worked with SPARC in RMO mode? Its
> fun because its so weak.
>

We discussed it already. I don't think that SPARCv9 RMO hardware
ever existed and you failed to convince me otherwise.

As to weakness, I don't think that by specification it is weaker than IPF,
may be not even weaker than POWER. Certainly stronger than Alpha.
But it does not matter since it does not exist.

> I still need to find that old paper called QPI, if I remember correctly.
> It should still be out there. I will try to find it sometime today.
>
> It think is was from Dice wrt a Java VM. David Dice? Damn I cannot
> remember it right now. Sorry. ;^o
>
>
> [...]

Re: Thread-safe initialization of static objects

<uevh5g$2m8qq$1@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 14:06:55 -0700
Organization: A noiseless patient Spider
Lines: 120
Message-ID: <uevh5g$2m8qq$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <20230924092501.340@kylheku.com>
<uetrjn$2car5$1@dont-email.me>
<e01f389c-3f23-47dc-89cd-a21038c6592an@googlegroups.com>
<uevd5n$2ligo$1@dont-email.me>
<5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Sep 2023 21:06:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2827098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LxWJVOb7FZQwFtVYjfN+4T4V+kHS1qXc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:OLDa2Dmi/psYNYxvvI4e/lxgnLk=
In-Reply-To: <5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 21:06 UTC

On 9/26/2023 1:58 PM, Michael S wrote:
> On Tuesday, September 26, 2023 at 10:59:06 PM UTC+3, Chris M. Thomasson wrote:
>> On 9/26/2023 9:05 AM, Michael S wrote:
>>> On Tuesday, September 26, 2023 at 8:53:13 AM UTC+3, Chris M. Thomasson wrote:
>>>> On 9/24/2023 10:04 AM, Kaz Kylheku wrote:
>>>>> On 2023-09-24, Bonita Montero <Bonita....@gmail.com> wrote:
>>>>>> Am 24.09.2023 um 04:22 schrieb Kaz Kylheku:
>>>>>>
>>>>>>> A possible design is that each *thread* has a wait semaphore.
>>>>>>
>>>>>> You'd have to register the binary semaphore and register as a waiter in
>>>>>> one atomic step. You could do that with a DCAS'd ring, but you coudn't
>>>>>> atomically update the link pointers of the other nodes at the same
>>>>>> time you update the roots link pointers. And you would have the deallo-
>>>>>> cation poblem, i.e. the memory of your object may never be deallocated.
>>>>>
>>>>> Now you're just throwing together words you don't understand.
>>>>>
>>>>>> Show me your implementation !
>>>>>
>>>>> E.g. old LinuxThreads in glibc, circa 2000:
>>>>>
>>>>> https://sourceware.org/git/?p=glibc.git;a=blob;f=linuxthreads/spinlock.c;h=5cd772602c8858edd8238e73eefcbf2758935d74;hb=d82e4c7bb231c9e0f835bd46467563ac3b56cebe
>>>>>
>>>>> The low level __pthread_lock and __pthread_unlock functions maintain a
>>>>> queue, using a single-word atomic CAS.
>>>>>
>>>>> There are suspend() and resume() functions for the waiting;
>>>>> they are elsewhere.
>>>>>
>>>>> If you look in restart.h you can see that those operations are defined
>>>>> in two different ways, both of which use signals (not a semaphore per
>>>>> thread). A suspending thread waits for the arrival of a signal,
>>>>> resume is done by sending a signal. That's kind of semaphore-like;
>>>>> and POSIX real-time signals can even queue up, like a counting sem.
>>>>>
>>>>>> It's ridiculous because mutex are a cheap resource. And if such imple-
>>>>>> mentation would be possible the standard shouldn't mandate it since
>>>>>> not every platform has a DCAS.
>>>>>
>>>>> Things can be done in ways you havn't thought about.
>>>>>
>>>>> Atomic operations aren't required to achieve mutual exclusion among
>>>>> processors that share memory.
>>>>>
>>>>> As someone continually insisting on having expertise in concurrency,
>>>>> you must be familiar with the research work of Leslie Lamport?
>>>>
>>>> Iirc, that uses atomic loads, stores and membars. Iirc, it requires a
>>>> #StoreLoad barrier on the SPARC. Iirc, it even requires an explicit
>>>> membar on the x86. MFENCE, or XCHG which has the lock prefix
>>>> automatically asserted. Humm... There is a way to get around that
>>>> bastard #StoreLoad membar... It uses an async sync setup. The funny
>>>> thing is that Windows has a API that can be used to actually implement
>>>> it! Try to think of a so called, remote memory barrier, in a sense:
>>>>
>>>> https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushprocesswritebuffers
>>>>
>>>> There is a way to use this to get an async mutex that is kind of sort of
>>>> akin to a read write mutex. Basically, the mutex is broken down into two
>>>> parts. One that represents accesses that _very_ frequently called upon.
>>>> The other one is used rather rarely. This is the async nature that can
>>>> be exploited in rather interesting ways. I implemented some in the past
>>>> with Dmitry Vyukov. Also, this FlushProcessWriteBuffers API can be used
>>>> to implement other rather exotic sync schemes. They have very excellent
>>>> performance for certain workloads. Actually, there is a way to use it to
>>>> get a RCU in userspace and/or hazard pointers without any explicit
>>>> #StoreLoad membars.
>>>>
>>>>
>>>
>>> I would expect FlushProcessWriteBuffers() to be 2 orders of magnitude
>>> slower than #StoreLoad membar. I could be wrong, of course, the function
>>> is close to undocumented.
>> FlushProcessWriteBuffers() can be used to gain a quiescent state wrt
>> memory visibility for some exotic async algorithms, it is called in
>> certain places and is RARE. However, on the other hand, having to use a
>> #StoreLoad membar on the fast path is not good. Keep in mind that this
>> is meant to handle a store followed by a load to another location
>> scenario. We need to honor the #StoreLoad relationship for this type of
>> setup for these types of algorithms. For instance, hazard pointers
>> require a #StoreLoad, however there is a way to eliminate them using
>> some special magic wrt RCU...
>>
>> My friend Joe Seigh created SMR+RCU to gain this. SMR is hazard
>> pointers. Now, keep in mind that these are very "specialized" algorithms
>> that try to make certain workloads MUCH faster and way more efficient.
>> They work for that.
>>
>> Also, keep in mind that a normal mutex does not require #StoreLoad. Only
>> acquire and release:
>>
>> acquire = #LoadStore | #LoadLoad
>> release = #LoadStore | #StoreStore
>>
>> In SPARC parlance. For instance, an atomic store on x86 automatically
>> implies release. Btw, have you ever worked with SPARC in RMO mode? Its
>> fun because its so weak.
>>
>
> We discussed it already. I don't think that SPARCv9 RMO hardware
> ever existed and you failed to convince me otherwise.

Iirc, SPARC64 V9 can put into RMO mode.

>
> As to weakness, I don't think that by specification it is weaker than IPF,
> may be not even weaker than POWER. Certainly stronger than Alpha.
> But it does not matter since it does not exist.
>
>> I still need to find that old paper called QPI, if I remember correctly.
>> It should still be out there. I will try to find it sometime today.
>>
>> It think is was from Dice wrt a Java VM. David Dice? Damn I cannot
>> remember it right now. Sorry. ;^o
>>
>>
>> [...]

Re: Thread-safe initialization of static objects

<uevh6q$2m8qq$2@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 14:07:37 -0700
Organization: A noiseless patient Spider
Lines: 120
Message-ID: <uevh6q$2m8qq$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <20230924092501.340@kylheku.com>
<uetrjn$2car5$1@dont-email.me>
<e01f389c-3f23-47dc-89cd-a21038c6592an@googlegroups.com>
<uevd5n$2ligo$1@dont-email.me>
<5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Sep 2023 21:07:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2827098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/aIXl2rTTjz1Au1+Cp0Ze326cCIMRbe7U="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:dQdc4XdVETna23VjlgyJi37p7DM=
In-Reply-To: <5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 21:07 UTC

On 9/26/2023 1:58 PM, Michael S wrote:
> On Tuesday, September 26, 2023 at 10:59:06 PM UTC+3, Chris M. Thomasson wrote:
>> On 9/26/2023 9:05 AM, Michael S wrote:
>>> On Tuesday, September 26, 2023 at 8:53:13 AM UTC+3, Chris M. Thomasson wrote:
>>>> On 9/24/2023 10:04 AM, Kaz Kylheku wrote:
>>>>> On 2023-09-24, Bonita Montero <Bonita....@gmail.com> wrote:
>>>>>> Am 24.09.2023 um 04:22 schrieb Kaz Kylheku:
>>>>>>
>>>>>>> A possible design is that each *thread* has a wait semaphore.
>>>>>>
>>>>>> You'd have to register the binary semaphore and register as a waiter in
>>>>>> one atomic step. You could do that with a DCAS'd ring, but you coudn't
>>>>>> atomically update the link pointers of the other nodes at the same
>>>>>> time you update the roots link pointers. And you would have the deallo-
>>>>>> cation poblem, i.e. the memory of your object may never be deallocated.
>>>>>
>>>>> Now you're just throwing together words you don't understand.
>>>>>
>>>>>> Show me your implementation !
>>>>>
>>>>> E.g. old LinuxThreads in glibc, circa 2000:
>>>>>
>>>>> https://sourceware.org/git/?p=glibc.git;a=blob;f=linuxthreads/spinlock.c;h=5cd772602c8858edd8238e73eefcbf2758935d74;hb=d82e4c7bb231c9e0f835bd46467563ac3b56cebe
>>>>>
>>>>> The low level __pthread_lock and __pthread_unlock functions maintain a
>>>>> queue, using a single-word atomic CAS.
>>>>>
>>>>> There are suspend() and resume() functions for the waiting;
>>>>> they are elsewhere.
>>>>>
>>>>> If you look in restart.h you can see that those operations are defined
>>>>> in two different ways, both of which use signals (not a semaphore per
>>>>> thread). A suspending thread waits for the arrival of a signal,
>>>>> resume is done by sending a signal. That's kind of semaphore-like;
>>>>> and POSIX real-time signals can even queue up, like a counting sem.
>>>>>
>>>>>> It's ridiculous because mutex are a cheap resource. And if such imple-
>>>>>> mentation would be possible the standard shouldn't mandate it since
>>>>>> not every platform has a DCAS.
>>>>>
>>>>> Things can be done in ways you havn't thought about.
>>>>>
>>>>> Atomic operations aren't required to achieve mutual exclusion among
>>>>> processors that share memory.
>>>>>
>>>>> As someone continually insisting on having expertise in concurrency,
>>>>> you must be familiar with the research work of Leslie Lamport?
>>>>
>>>> Iirc, that uses atomic loads, stores and membars. Iirc, it requires a
>>>> #StoreLoad barrier on the SPARC. Iirc, it even requires an explicit
>>>> membar on the x86. MFENCE, or XCHG which has the lock prefix
>>>> automatically asserted. Humm... There is a way to get around that
>>>> bastard #StoreLoad membar... It uses an async sync setup. The funny
>>>> thing is that Windows has a API that can be used to actually implement
>>>> it! Try to think of a so called, remote memory barrier, in a sense:
>>>>
>>>> https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushprocesswritebuffers
>>>>
>>>> There is a way to use this to get an async mutex that is kind of sort of
>>>> akin to a read write mutex. Basically, the mutex is broken down into two
>>>> parts. One that represents accesses that _very_ frequently called upon.
>>>> The other one is used rather rarely. This is the async nature that can
>>>> be exploited in rather interesting ways. I implemented some in the past
>>>> with Dmitry Vyukov. Also, this FlushProcessWriteBuffers API can be used
>>>> to implement other rather exotic sync schemes. They have very excellent
>>>> performance for certain workloads. Actually, there is a way to use it to
>>>> get a RCU in userspace and/or hazard pointers without any explicit
>>>> #StoreLoad membars.
>>>>
>>>>
>>>
>>> I would expect FlushProcessWriteBuffers() to be 2 orders of magnitude
>>> slower than #StoreLoad membar. I could be wrong, of course, the function
>>> is close to undocumented.
>> FlushProcessWriteBuffers() can be used to gain a quiescent state wrt
>> memory visibility for some exotic async algorithms, it is called in
>> certain places and is RARE. However, on the other hand, having to use a
>> #StoreLoad membar on the fast path is not good. Keep in mind that this
>> is meant to handle a store followed by a load to another location
>> scenario. We need to honor the #StoreLoad relationship for this type of
>> setup for these types of algorithms. For instance, hazard pointers
>> require a #StoreLoad, however there is a way to eliminate them using
>> some special magic wrt RCU...
>>
>> My friend Joe Seigh created SMR+RCU to gain this. SMR is hazard
>> pointers. Now, keep in mind that these are very "specialized" algorithms
>> that try to make certain workloads MUCH faster and way more efficient.
>> They work for that.
>>
>> Also, keep in mind that a normal mutex does not require #StoreLoad. Only
>> acquire and release:
>>
>> acquire = #LoadStore | #LoadLoad
>> release = #LoadStore | #StoreStore
>>
>> In SPARC parlance. For instance, an atomic store on x86 automatically
>> implies release. Btw, have you ever worked with SPARC in RMO mode? Its
>> fun because its so weak.
>>
>
> We discussed it already. I don't think that SPARCv9 RMO hardware
> ever existed and you failed to convince me otherwise.

Have you ever used SPARC before? Solaris?

>
> As to weakness, I don't think that by specification it is weaker than IPF,
> may be not even weaker than POWER. Certainly stronger than Alpha.
> But it does not matter since it does not exist.
>
>> I still need to find that old paper called QPI, if I remember correctly.
>> It should still be out there. I will try to find it sometime today.
>>
>> It think is was from Dice wrt a Java VM. David Dice? Damn I cannot
>> remember it right now. Sorry. ;^o
>>
>>
>> [...]

Re: Thread-safe initialization of static objects

<uevhe1$2m8qq$3@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 14:11:28 -0700
Organization: A noiseless patient Spider
Lines: 108
Message-ID: <uevhe1$2m8qq$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <20230924092501.340@kylheku.com>
<uetrjn$2car5$1@dont-email.me>
<e01f389c-3f23-47dc-89cd-a21038c6592an@googlegroups.com>
<uevd5n$2ligo$1@dont-email.me>
<5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Sep 2023 21:11:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2827098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QbdVJ1Uz3lwr1e1pfF7RW37tWYLcs+ag="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:wE1rhMkDS5Um32yY9Ux+T9ul5wQ=
In-Reply-To: <5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 21:11 UTC

On 9/26/2023 1:58 PM, Michael S wrote:
> On Tuesday, September 26, 2023 at 10:59:06 PM UTC+3, Chris M. Thomasson wrote:
>> On 9/26/2023 9:05 AM, Michael S wrote:
>>> On Tuesday, September 26, 2023 at 8:53:13 AM UTC+3, Chris M. Thomasson wrote:
>>>> On 9/24/2023 10:04 AM, Kaz Kylheku wrote:
>>>>> On 2023-09-24, Bonita Montero <Bonita....@gmail.com> wrote:
>>>>>> Am 24.09.2023 um 04:22 schrieb Kaz Kylheku:
>>>>>>
>>>>>>> A possible design is that each *thread* has a wait semaphore.
>>>>>>
>>>>>> You'd have to register the binary semaphore and register as a waiter in
>>>>>> one atomic step. You could do that with a DCAS'd ring, but you coudn't
>>>>>> atomically update the link pointers of the other nodes at the same
>>>>>> time you update the roots link pointers. And you would have the deallo-
>>>>>> cation poblem, i.e. the memory of your object may never be deallocated.
>>>>>
>>>>> Now you're just throwing together words you don't understand.
>>>>>
>>>>>> Show me your implementation !
>>>>>
>>>>> E.g. old LinuxThreads in glibc, circa 2000:
>>>>>
>>>>> https://sourceware.org/git/?p=glibc.git;a=blob;f=linuxthreads/spinlock.c;h=5cd772602c8858edd8238e73eefcbf2758935d74;hb=d82e4c7bb231c9e0f835bd46467563ac3b56cebe
>>>>>
>>>>> The low level __pthread_lock and __pthread_unlock functions maintain a
>>>>> queue, using a single-word atomic CAS.
>>>>>
>>>>> There are suspend() and resume() functions for the waiting;
>>>>> they are elsewhere.
>>>>>
>>>>> If you look in restart.h you can see that those operations are defined
>>>>> in two different ways, both of which use signals (not a semaphore per
>>>>> thread). A suspending thread waits for the arrival of a signal,
>>>>> resume is done by sending a signal. That's kind of semaphore-like;
>>>>> and POSIX real-time signals can even queue up, like a counting sem.
>>>>>
>>>>>> It's ridiculous because mutex are a cheap resource. And if such imple-
>>>>>> mentation would be possible the standard shouldn't mandate it since
>>>>>> not every platform has a DCAS.
>>>>>
>>>>> Things can be done in ways you havn't thought about.
>>>>>
>>>>> Atomic operations aren't required to achieve mutual exclusion among
>>>>> processors that share memory.
>>>>>
>>>>> As someone continually insisting on having expertise in concurrency,
>>>>> you must be familiar with the research work of Leslie Lamport?
>>>>
>>>> Iirc, that uses atomic loads, stores and membars. Iirc, it requires a
>>>> #StoreLoad barrier on the SPARC. Iirc, it even requires an explicit
>>>> membar on the x86. MFENCE, or XCHG which has the lock prefix
>>>> automatically asserted. Humm... There is a way to get around that
>>>> bastard #StoreLoad membar... It uses an async sync setup. The funny
>>>> thing is that Windows has a API that can be used to actually implement
>>>> it! Try to think of a so called, remote memory barrier, in a sense:
>>>>
>>>> https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushprocesswritebuffers
>>>>
>>>> There is a way to use this to get an async mutex that is kind of sort of
>>>> akin to a read write mutex. Basically, the mutex is broken down into two
>>>> parts. One that represents accesses that _very_ frequently called upon.
>>>> The other one is used rather rarely. This is the async nature that can
>>>> be exploited in rather interesting ways. I implemented some in the past
>>>> with Dmitry Vyukov. Also, this FlushProcessWriteBuffers API can be used
>>>> to implement other rather exotic sync schemes. They have very excellent
>>>> performance for certain workloads. Actually, there is a way to use it to
>>>> get a RCU in userspace and/or hazard pointers without any explicit
>>>> #StoreLoad membars.
>>>>
>>>>
>>>
>>> I would expect FlushProcessWriteBuffers() to be 2 orders of magnitude
>>> slower than #StoreLoad membar. I could be wrong, of course, the function
>>> is close to undocumented.
>> FlushProcessWriteBuffers() can be used to gain a quiescent state wrt
>> memory visibility for some exotic async algorithms, it is called in
>> certain places and is RARE. However, on the other hand, having to use a
>> #StoreLoad membar on the fast path is not good. Keep in mind that this
>> is meant to handle a store followed by a load to another location
>> scenario. We need to honor the #StoreLoad relationship for this type of
>> setup for these types of algorithms. For instance, hazard pointers
>> require a #StoreLoad, however there is a way to eliminate them using
>> some special magic wrt RCU...
>>
>> My friend Joe Seigh created SMR+RCU to gain this. SMR is hazard
>> pointers. Now, keep in mind that these are very "specialized" algorithms
>> that try to make certain workloads MUCH faster and way more efficient.
>> They work for that.
>>
>> Also, keep in mind that a normal mutex does not require #StoreLoad. Only
>> acquire and release:
>>
>> acquire = #LoadStore | #LoadLoad
>> release = #LoadStore | #StoreStore
>>
>> In SPARC parlance. For instance, an atomic store on x86 automatically
>> implies release. Btw, have you ever worked with SPARC in RMO mode? Its
>> fun because its so weak.
>>
>
> We discussed it already. I don't think that SPARCv9 RMO hardware
> ever existed and you failed to convince me otherwise.

[...]

heck, have you ever had to use a DEC Alpha that was so weak it did not
even honor data dependent loads? This is interesting wrt RCU... ;^)

Re: Thread-safe initialization of static objects

<uevhpp$2m8qq$4@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 14:17:44 -0700
Organization: A noiseless patient Spider
Lines: 112
Message-ID: <uevhpp$2m8qq$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <20230924092501.340@kylheku.com>
<uetrjn$2car5$1@dont-email.me>
<e01f389c-3f23-47dc-89cd-a21038c6592an@googlegroups.com>
<uevd5n$2ligo$1@dont-email.me>
<5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Sep 2023 21:17:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2827098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19V/8hdDewjaedbVsPfSHitd2Tp7JFiowo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:dsmNa1w+p2D6kLlqAr+CeCFhy7E=
In-Reply-To: <5694c62a-9ebc-434d-8496-2475ed56d7b4n@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 21:17 UTC

On 9/26/2023 1:58 PM, Michael S wrote:
> On Tuesday, September 26, 2023 at 10:59:06 PM UTC+3, Chris M. Thomasson wrote:
>> On 9/26/2023 9:05 AM, Michael S wrote:
>>> On Tuesday, September 26, 2023 at 8:53:13 AM UTC+3, Chris M. Thomasson wrote:
>>>> On 9/24/2023 10:04 AM, Kaz Kylheku wrote:
>>>>> On 2023-09-24, Bonita Montero <Bonita....@gmail.com> wrote:
>>>>>> Am 24.09.2023 um 04:22 schrieb Kaz Kylheku:
>>>>>>
>>>>>>> A possible design is that each *thread* has a wait semaphore.
>>>>>>
>>>>>> You'd have to register the binary semaphore and register as a waiter in
>>>>>> one atomic step. You could do that with a DCAS'd ring, but you coudn't
>>>>>> atomically update the link pointers of the other nodes at the same
>>>>>> time you update the roots link pointers. And you would have the deallo-
>>>>>> cation poblem, i.e. the memory of your object may never be deallocated.
>>>>>
>>>>> Now you're just throwing together words you don't understand.
>>>>>
>>>>>> Show me your implementation !
>>>>>
>>>>> E.g. old LinuxThreads in glibc, circa 2000:
>>>>>
>>>>> https://sourceware.org/git/?p=glibc.git;a=blob;f=linuxthreads/spinlock.c;h=5cd772602c8858edd8238e73eefcbf2758935d74;hb=d82e4c7bb231c9e0f835bd46467563ac3b56cebe
>>>>>
>>>>> The low level __pthread_lock and __pthread_unlock functions maintain a
>>>>> queue, using a single-word atomic CAS.
>>>>>
>>>>> There are suspend() and resume() functions for the waiting;
>>>>> they are elsewhere.
>>>>>
>>>>> If you look in restart.h you can see that those operations are defined
>>>>> in two different ways, both of which use signals (not a semaphore per
>>>>> thread). A suspending thread waits for the arrival of a signal,
>>>>> resume is done by sending a signal. That's kind of semaphore-like;
>>>>> and POSIX real-time signals can even queue up, like a counting sem.
>>>>>
>>>>>> It's ridiculous because mutex are a cheap resource. And if such imple-
>>>>>> mentation would be possible the standard shouldn't mandate it since
>>>>>> not every platform has a DCAS.
>>>>>
>>>>> Things can be done in ways you havn't thought about.
>>>>>
>>>>> Atomic operations aren't required to achieve mutual exclusion among
>>>>> processors that share memory.
>>>>>
>>>>> As someone continually insisting on having expertise in concurrency,
>>>>> you must be familiar with the research work of Leslie Lamport?
>>>>
>>>> Iirc, that uses atomic loads, stores and membars. Iirc, it requires a
>>>> #StoreLoad barrier on the SPARC. Iirc, it even requires an explicit
>>>> membar on the x86. MFENCE, or XCHG which has the lock prefix
>>>> automatically asserted. Humm... There is a way to get around that
>>>> bastard #StoreLoad membar... It uses an async sync setup. The funny
>>>> thing is that Windows has a API that can be used to actually implement
>>>> it! Try to think of a so called, remote memory barrier, in a sense:
>>>>
>>>> https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushprocesswritebuffers
>>>>
>>>> There is a way to use this to get an async mutex that is kind of sort of
>>>> akin to a read write mutex. Basically, the mutex is broken down into two
>>>> parts. One that represents accesses that _very_ frequently called upon.
>>>> The other one is used rather rarely. This is the async nature that can
>>>> be exploited in rather interesting ways. I implemented some in the past
>>>> with Dmitry Vyukov. Also, this FlushProcessWriteBuffers API can be used
>>>> to implement other rather exotic sync schemes. They have very excellent
>>>> performance for certain workloads. Actually, there is a way to use it to
>>>> get a RCU in userspace and/or hazard pointers without any explicit
>>>> #StoreLoad membars.
>>>>
>>>>
>>>
>>> I would expect FlushProcessWriteBuffers() to be 2 orders of magnitude
>>> slower than #StoreLoad membar. I could be wrong, of course, the function
>>> is close to undocumented.
>> FlushProcessWriteBuffers() can be used to gain a quiescent state wrt
>> memory visibility for some exotic async algorithms, it is called in
>> certain places and is RARE. However, on the other hand, having to use a
>> #StoreLoad membar on the fast path is not good. Keep in mind that this
>> is meant to handle a store followed by a load to another location
>> scenario. We need to honor the #StoreLoad relationship for this type of
>> setup for these types of algorithms. For instance, hazard pointers
>> require a #StoreLoad, however there is a way to eliminate them using
>> some special magic wrt RCU...
>>
>> My friend Joe Seigh created SMR+RCU to gain this. SMR is hazard
>> pointers. Now, keep in mind that these are very "specialized" algorithms
>> that try to make certain workloads MUCH faster and way more efficient.
>> They work for that.
>>
>> Also, keep in mind that a normal mutex does not require #StoreLoad. Only
>> acquire and release:
>>
>> acquire = #LoadStore | #LoadLoad
>> release = #LoadStore | #StoreStore
>>
>> In SPARC parlance. For instance, an atomic store on x86 automatically
>> implies release. Btw, have you ever worked with SPARC in RMO mode? Its
>> fun because its so weak.
>>
>
> We discussed it already. I don't think that SPARCv9 RMO hardware
> ever existed and you failed to convince me otherwise.
>
> As to weakness, I don't think that by specification it is weaker than IPF,
> may be not even weaker than POWER. Certainly stronger than Alpha.

The damn DEC Alpha did not even honor data-dependent loads, that is very
weak. It's so weak it has to use membars to implement RCU.

Sparc in RMO mode requires explicit MEMBAR for acquire and release. IN
TSO mode it had implicit acquire and release wrt loads and stores much
like x86.

Re: Thread-safe initialization of static objects

<uevkna$2mqsq$2@dont-email.me>

  copy mid

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

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

On 9/25/2023 11:08 AM, Kaz Kylheku wrote:
> On 2023-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 25.09.2023 um 13:15 schrieb Richard Damon:
>>
>>> You argument is basically, the Standard needs to allow for BAD
>>> implementation to exist.
>>
>> And implementation that throws in this situation isn't bad for me.
>
> An implementation that throws in mutex locks that aren't process-shared
> robust mutexes or anything of that sort is a ... sick joke.
>

Big time.

Re: Thread-safe initialization of static objects

<uevltn$2n4vj$1@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 15:28:06 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <uevltn$2n4vj$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <ue4p5v$3truj$1@dont-email.me>
<ue4t6i$3um57$1@dont-email.me> <ue5sp2$7ms9$1@dont-email.me>
<ue7gb8$fumm$3@dont-email.me> <ue7gkn$g3o5$1@dont-email.me>
<20230917121015.206@kylheku.com> <ue7k2n$gmqv$1@dont-email.me>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<DUVOM.87557$noZ7.33800@fx13.iad> <uehdjj$3h8me$3@dont-email.me>
<uei1je$3l13h$3@dont-email.me> <20230921114029.796@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 22:28:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="2855923"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UNowB1cP4aqmFFKDFLb/QCYOLJx0cOqw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:o4QzLBu3r9My9Wi61cXb4zNsN1c=
In-Reply-To: <20230921114029.796@kylheku.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 22:28 UTC

On 9/21/2023 11:42 AM, Kaz Kylheku wrote:
> On 2023-09-21, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>> On 9/21/2023 5:40 AM, Bonita Montero wrote:
>>> Am 21.09.2023 um 13:36 schrieb Richard Damon:
>>>
>>>> Why?
>>>
>>> Because the initialization might only take a microsecond or less
>>> and a yield is a full timeslice, on Linux and Windows usually one
>>> millisecond.
>>
>> An adaptive backoff can be a mixture of the PAUSE instruction aka x86,
>> and yield wrt the OS.
>
> Ideally there shouldn't be a difference? In user mode execution, PAUSE
> should be a privileged instruction. User space must not pause the
> machine until an interrupt occurs. The privileged instruction will trap
> to the kernel, where it becomes equivalent to a yield().
>
> In the kernel, the lowest-priority idle task might execute that
> instruction in a loop: the real one, not the trap.
>
> When the scheduler determines there is truly nothing to do then it is
> legitimate to dispatch an idle task which suspends the processor until
> an external event.
>

Wrt adaptive backoff, did you ever read the following paper?

https://dl.acm.org/doi/10.1145/2686884

Iirc, David was an author on the paper I am having trouble finding wrt QPI.

Re: Thread-safe initialization of static objects

<uevm4l$2n4vj$2@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 15:31:47 -0700
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <uevm4l$2n4vj$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <ue4p5v$3truj$1@dont-email.me>
<ue4t6i$3um57$1@dont-email.me> <ue5sp2$7ms9$1@dont-email.me>
<ue7gb8$fumm$3@dont-email.me> <ue7gkn$g3o5$1@dont-email.me>
<20230917121015.206@kylheku.com> <ue7k2n$gmqv$1@dont-email.me>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me> <uebn4f$293m3$2@dont-email.me>
<1GhOM.7399$H0Ge.6907@fx05.iad> <uecac1$2cj86$1@dont-email.me>
<iwpOM.265$Sn81.181@fx08.iad> <uedp93$2orvq$2@dont-email.me>
<k4BOM.2058$TwR4.78@fx46.iad> <ueeret$2upib$1@dont-email.me>
<JCKOM.83797$2ph4.24937@fx14.iad> <uege3r$3bfsj$2@dont-email.me>
<DUVOM.87557$noZ7.33800@fx13.iad> <uehdjj$3h8me$3@dont-email.me>
<uei1je$3l13h$3@dont-email.me> <20230921114029.796@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 22:31:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="2855923"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+G2CKbXWnBfEwpe4LU8cqC3pu8Jqdvw6E="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:pyG2N/JDmegPqqQga12zeQ1KYTY=
In-Reply-To: <20230921114029.796@kylheku.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 22:31 UTC

On 9/21/2023 11:42 AM, Kaz Kylheku wrote:
> On 2023-09-21, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>> On 9/21/2023 5:40 AM, Bonita Montero wrote:
>>> Am 21.09.2023 um 13:36 schrieb Richard Damon:
>>>
>>>> Why?
>>>
>>> Because the initialization might only take a microsecond or less
>>> and a yield is a full timeslice, on Linux and Windows usually one
>>> millisecond.
>>
>> An adaptive backoff can be a mixture of the PAUSE instruction aka x86,
>> and yield wrt the OS.
>
> Ideally there shouldn't be a difference? In user mode execution, PAUSE
> should be a privileged instruction. User space must not pause the
> machine until an interrupt occurs. The privileged instruction will trap
> to the kernel, where it becomes equivalent to a yield().
>
> In the kernel, the lowest-priority idle task might execute that
> instruction in a loop: the real one, not the trap.
>
> When the scheduler determines there is truly nothing to do then it is
> legitimate to dispatch an idle task which suspends the processor until
> an external event.
>

Damn it! I cannot find that paper wrt QPI or the quick path interconnect
wrt Intel, and how to abuse it for even a userspace RCU.

Re: Thread-safe initialization of static objects

<P3JQM.47865$2XR1.45635@fx43.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx43.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<mzkPM.16155$ugs.3977@fx36.iad> <uekler$bqj8$1@dont-email.me>
<20230922111441.730@kylheku.com> <uelq9h$lo9j$2@dont-email.me>
<20230923041951.728@kylheku.com> <uemlbj$pl2d$1@dont-email.me>
<20230923185708.811@kylheku.com> <ueoqpa$19436$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
<ZYdQM.67167$3vM.17655@fx37.iad> <uerv9b$1tqis$1@dont-email.me>
<LJoQM.19137$EIy4.5875@fx48.iad> <uetn46$2bkun$1@dont-email.me>
<20230925214046.531@kylheku.com> <ueu77t$2ebas$1@dont-email.me>
<8bzQM.36477$q0k.24969@fx34.iad> <ueuj7i$2gdqk$2@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
Content-Language: en-US
In-Reply-To: <ueuj7i$2gdqk$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 22
Message-ID: <P3JQM.47865$2XR1.45635@fx43.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 26 Sep 2023 18:38:39 -0400
X-Received-Bytes: 2555
 by: Richard Damon - Tue, 26 Sep 2023 22:38 UTC

On 9/26/23 8:36 AM, Bonita Montero wrote:
> Am 26.09.2023 um 13:23 schrieb Richard Damon:
>
>> Nope, if you do it right, a suitable synchronization object can be
>> created without possibility of error.
>
> The kernel part for the slow path is a binary semaphore. You can't
> create an aribtrary number of that on any operating system. Yieling
> is inefficient and I also mentioned why spin-locking is totally
> inacceptable.
>

Only if you do it wrong, like you are doing.

You THINK yielding is inefficient, but it really isn't.

IT only gives time to other threads that actually need it, so the
processor is kept doing useful work.

You also don't seem to understand how Schedulers ACTUALLY WORK.

Just shows your ignorance.

Re: Thread-safe initialization of static objects

<v5JQM.47866$2XR1.28331@fx43.iad>

  copy mid

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

  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!fx43.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ueutjo$2ii89$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 19
Message-ID: <v5JQM.47866$2XR1.28331@fx43.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 26 Sep 2023 18:40:27 -0400
X-Received-Bytes: 1990
 by: Richard Damon - Tue, 26 Sep 2023 22:40 UTC

On 9/26/23 11:33 AM, Bonita Montero wrote:
> Am 26.09.2023 um 17:24 schrieb Scott Lurndal:
>
>> No, it is not.   The kernel simply moves the waiter thread to
>> a non-runnable queue in the dispatcher until a call to 'unlock'
>> determines that there is a waiter and tells the kernel to
>> awaken it.
>
> The userspace code must tell the kernel what it its waiting for.
> Mutexes are always a combination of an atomic for the fast path
> and a binary semapohre for the slow path.
>

Sorry to tell you that you are just wrong.

Please point to the code in the kernal that actually does this.

If you can't, your just admitting that you have been lying about knowing
how it works.

Re: Thread-safe initialization of static objects

<20230926161154.170@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 23:16:04 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <20230926161154.170@kylheku.com>
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> <20230926100151.733@kylheku.com>
<uev4kk$2jugo$2@dont-email.me>
Injection-Date: Tue, 26 Sep 2023 23:16:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c0e01ce6519512ba10a3c818fb613fd9";
logging-data="2868683"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oZZXDTUonDvQY58EDNWWPG4pZSelanBc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:dyIKYpKIPgQfBRxPu5/8rcCb5qM=
 by: Kaz Kylheku - Tue, 26 Sep 2023 23:16 UTC

On 2023-09-26, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 26.09.2023 um 19:09 schrieb Kaz Kylheku:
>
>> In Linux, the original threads implementation in Glibc, based on
>> Xavier Leroy's LinuxThreads didn't use one semaphore per mutex.
>> It used POSIX signals to implement internal functions suspend()
>> and resume(). There was no kernel object to allocate.
>
> Maybe, but the C++ standard shoudn't mandate that. If you implement
> a mutex yourself under Windows you'd need a kernel event or semaphore.

Only if you had no imagination, research abilility, or skills for
porting ideas from elsewhere to Windows.

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

<5XKQM.308122$ZXz4.72929@fx18.iad>

  copy mid

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

  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
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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>
<1tzQM.252985$2ph4.238002@fx14.iad> <ueuj3l$2gdqk$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ueuj3l$2gdqk$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 51
Message-ID: <5XKQM.308122$ZXz4.72929@fx18.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 26 Sep 2023 20:45:53 -0400
X-Received-Bytes: 4153
 by: Richard Damon - Wed, 27 Sep 2023 00:45 UTC

On 9/26/23 8:33 AM, Bonita Montero wrote:
> Am 26.09.2023 um 13:42 schrieb Richard Damon:
>
>> Again, your argument boils down to: Even though there is a way to do
>> it  without failure, the fact that another, "defective" way exists
>> that might generate an error, the Standard should be modified so that
>> "defective" method can be used.
>
> Pthread mutexes can be initialized statically, but then you have the
> same kind of delayed inititialization - which may fail. Or if you
> create the kernel part along with the initialization dynamically;
> then it doesn't fit with std::mutex' constructor which is noexcept.
> So in either way this operation may fail.
> I don't know what's the problem for further discussions that ::lock()
> simply may fail at least because of delayed initialization, on some
> operating systems also because of synchronization.
> And the standard can't assume a certain operation but in my opinion
> even has to assume that there are platforms that even may fail on
> synchronization, maybe because the kernel queue entries are allocated
> dynamically or whatevery.
> And it's the same for static local initialization, no matter if this
> initialization actually uses a std::mutex or whatever - because in
> any case there's a mutex behind to make contending threads sleeping
> as documented by the stdandardd. I also mentioned many times why
> yieling is inefficient and unprofessional here.
>

Please point to the error that a properly created and used pthread_mutex
can give on a lock that represents a mutex creation error.

Remember, we are talking about in INTRA-process mutex, not an
INTER-process mutex.

Yes, C++ allows lock to fails if the OS gives an error, but in POSIX
there is no error possible for this type of mutex when used correctly.

You keep on thinking that something can fail, and yes, it can if you do
things wrong, but not if you do things right.

All you are arguing is that the Standard should allow BUGGY
implementations to still be correct.

I guess this just shows the quality of your own code, that you need
people to accept your buggy code as correct.

Those of us who have to write code that actually works correctly, will
disagree with you, and we will be correct, and you wrong.

You have really effectively admitted you are lying because you have made
claims that have been shown to be totally incorrect.

Re: Thread-safe initialization of static objects

<biLQM.176420$1B%c.159187@fx09.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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> <20230926100151.733@kylheku.com>
<uev4kk$2jugo$2@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <uev4kk$2jugo$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 27
Message-ID: <biLQM.176420$1B%c.159187@fx09.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 26 Sep 2023 21:10:31 -0400
X-Received-Bytes: 2486
 by: Richard Damon - Wed, 27 Sep 2023 01:10 UTC

On 9/26/23 1:33 PM, Bonita Montero wrote:
> Am 26.09.2023 um 19:09 schrieb Kaz Kylheku:
>
>> In Linux, the original threads implementation in Glibc, based on
>> Xavier Leroy's LinuxThreads didn't use one semaphore per mutex.
>> It used POSIX signals to implement internal functions suspend()
>> and resume().  There was no kernel object to allocate.
>
> Maybe, but the C++ standard shoudn't mandate that. If you implement
> a mutex yourself under Windows you'd need a kernel event or semaphore.
>
>

Right, but if your mutexs can fail, you can't use them for static
initialization that can't fail.

All you keep on doing is insisting that the Standard needs to allow for
buggy implementations. It doesn't.

The Standard gives allowance at times for hardware platforms with
certain limitations, but tends not to give allowance for the implementer
just being lazy.

It may allow an implementation to minimize the work it needs to do to
have a (barely) compliant implementation, but does require the
implementer to put in the work (and have the knowledge) to actually
implement things correctly.

Re: Thread-safe initialization of static objects

<3DLQM.26649$EPT1.1768@fx02.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx02.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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>
<18c909bc-a09f-46e2-af03-a41dc071d73en@googlegroups.com>
<ueuvlp$2ivla$1@dont-email.me>
<9bd2422d-f363-47b3-a01e-256d228c59bcn@googlegroups.com>
<uev4fr$2jugo$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <uev4fr$2jugo$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 19
Message-ID: <3DLQM.26649$EPT1.1768@fx02.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 26 Sep 2023 21:32:47 -0400
X-Received-Bytes: 2308
 by: Richard Damon - Wed, 27 Sep 2023 01:32 UTC

On 9/26/23 1:30 PM, Bonita Montero wrote:
> Am 26.09.2023 um 19:00 schrieb Michael S:
>
>> If you were reading my post up to the end you were understanding that
>> such possibility is extremely low.
>
> I think that's a common optimization since in many cases mutexes aren't
> contended at all, thereby not needing any semaphore, or contended very
> late.
>

This just shows your whole problem. You "Think" something is a given
way, but you don't actually KNOW any of the stuff you claim (you can't,
since so much is false).

Your instance that it must be "your way" is just proving your ignorance.

When asked for proof, you just waffle, which just proves your ignorance
of the topic, and that your claims are without merit.

Re: Thread-safe initialization of static objects

<uf03b5$2t2h2$1@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 19:17:08 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <uf03b5$2t2h2$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> <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>
<18c909bc-a09f-46e2-af03-a41dc071d73en@googlegroups.com>
<ueuvlp$2ivla$1@dont-email.me>
<9bd2422d-f363-47b3-a01e-256d228c59bcn@googlegroups.com>
<uev4fr$2jugo$1@dont-email.me> <3DLQM.26649$EPT1.1768@fx02.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 02:17:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="3050018"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194j/e9gvLLlN/RBhkPL+5We68/vJyEejU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:abwIyGm7uIoi5InQW8RB+7Ey5sU=
In-Reply-To: <3DLQM.26649$EPT1.1768@fx02.iad>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 27 Sep 2023 02:17 UTC

On 9/26/2023 6:32 PM, Richard Damon wrote:
> On 9/26/23 1:30 PM, Bonita Montero wrote:
>> Am 26.09.2023 um 19:00 schrieb Michael S:
>>
>>> If you were reading my post up to the end you were understanding that
>>> such possibility is extremely low.
>>
>> I think that's a common optimization since in many cases mutexes aren't
>> contended at all, thereby not needing any semaphore, or contended very
>> late.
>>
>
> This just shows your whole problem. You "Think" something is a given
> way, but you don't actually KNOW any of the stuff you claim (you can't,
> since so much is false).
>
> Your instance that it must be "your way" is just proving your ignorance.
>
> When asked for proof, you just waffle, which just proves your ignorance
> of the topic, and that your claims are without merit.

I think that about sums it up, in a sense?

Re: Thread-safe initialization of static objects

<uf03ch$2t2h2$2@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 19:17:52 -0700
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <uf03ch$2t2h2$2@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> <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> <20230926100151.733@kylheku.com>
<uev4kk$2jugo$2@dont-email.me> <biLQM.176420$1B%c.159187@fx09.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 02:17:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="3050018"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YJrrKJ088FZjQ/0DMVZpxhcvKrnE4zEk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:LQ3jP1JC6zuh5jcX8MA8GK7LyLE=
In-Reply-To: <biLQM.176420$1B%c.159187@fx09.iad>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 27 Sep 2023 02:17 UTC

On 9/26/2023 6:10 PM, Richard Damon wrote:
> On 9/26/23 1:33 PM, Bonita Montero wrote:
>> Am 26.09.2023 um 19:09 schrieb Kaz Kylheku:
>>
>>> In Linux, the original threads implementation in Glibc, based on
>>> Xavier Leroy's LinuxThreads didn't use one semaphore per mutex.
>>> It used POSIX signals to implement internal functions suspend()
>>> and resume().  There was no kernel object to allocate.
>>
>> Maybe, but the C++ standard shoudn't mandate that. If you implement
>> a mutex yourself under Windows you'd need a kernel event or semaphore.
>>
>>
>
> Right, but if your mutexs can fail, you can't use them for static
> initialization that can't fail.

Excellent point! :^)

>
> All you keep on doing is insisting that the Standard needs to allow for
> buggy implementations. It doesn't.
>
> The Standard gives allowance at times for hardware platforms with
> certain limitations, but tends not to give allowance for the implementer
> just being lazy.
>
> It may allow an implementation to minimize the work it needs to do to
> have a (barely) compliant implementation, but does require the
> implementer to put in the work (and have the knowledge) to actually
> implement things correctly.

Re: Thread-safe initialization of static objects

<uf03un$2t2h2$3@dont-email.me>

  copy mid

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

  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: Tue, 26 Sep 2023 19:27:34 -0700
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <uf03un$2t2h2$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me>
<37dbe3b6-ead0-487b-884c-197124888eben@googlegroups.com>
<uepvs7$1ff81$3@dont-email.me> <ueq0bm$1fihu$2@dont-email.me>
<3ae49bbf-2fb6-47c1-83a6-402cf9656737n@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 02:27:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="3050018"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2/Z5o2tgT89tx8Ujx5JajFs42C25outk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:GtVQp+qUm51fqlEeyTs7zMV1qrc=
Content-Language: en-US
In-Reply-To: <3ae49bbf-2fb6-47c1-83a6-402cf9656737n@googlegroups.com>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 02:27 UTC

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

You just need to be in an alterable wait and be ready to handle it.
Okay. However, fwiw, check out how this following library handles async
pthread cancellation. Iirc, they used the kernel.

https://sourceware.org/pthreads-win32/

Btw, this lib has been around for a while.

> At least it is easy as long as you don't try to enter alertable wait
> within APC routine, which I don't do. In fact, my APC routine is Nop.
>
>>>> It uses one global mutex (in form of critical section) for a short
>>>> while for metadata updates, but that's done for simplicity and
>>>> practicality rather than out of necessity. I am pretty sure that
>>>> with enough effort I can device a variant that achieves the same
>>>> with CaS.
>>>
>>>

Re: Thread-safe initialization of static objects

<f53d5287-5892-4f05-8cf4-02d44c7b417an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:181a:b0:411:fe24:ab9d with SMTP id t26-20020a05622a181a00b00411fe24ab9dmr66864qtc.3.1695800189834;
Wed, 27 Sep 2023 00:36:29 -0700 (PDT)
X-Received: by 2002:a05:6808:1b0c:b0:3a7:2570:dd11 with SMTP id
bx12-20020a0568081b0c00b003a72570dd11mr572117oib.6.1695800189609; Wed, 27 Sep
2023 00:36:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!45.76.7.193.MISMATCH!3.us.feeder.erje.net!feeder.erje.net!border-1.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: Wed, 27 Sep 2023 00:36:29 -0700 (PDT)
In-Reply-To: <uf03un$2t2h2$3@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> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me> <37dbe3b6-ead0-487b-884c-197124888eben@googlegroups.com>
<uepvs7$1ff81$3@dont-email.me> <ueq0bm$1fihu$2@dont-email.me>
<3ae49bbf-2fb6-47c1-83a6-402cf9656737n@googlegroups.com> <uf03un$2t2h2$3@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f53d5287-5892-4f05-8cf4-02d44c7b417an@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Wed, 27 Sep 2023 07:36:29 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 60
 by: Michael S - Wed, 27 Sep 2023 07:36 UTC

On Wednesday, September 27, 2023 at 5:27:52 AM UTC+3, Chris M. Thomasson wrote:
> On 9/25/2023 10:20 AM, Michael S wrote:
> > On Sunday, September 24, 2023 at 9:49:44 PM UTC+3, Chris M. Thomasson wrote:
> >> On 9/24/2023 11:41 AM, Chris M. Thomasson wrote:
> >>> On 9/24/2023 2:50 AM, Michael S wrote:
> >>>> On Sunday, September 24, 2023 at 11:09:31 AM UTC+3, Bonita Montero wrote:
> >>>>> Am 24.09.2023 um 05:05 schrieb Chris M. Thomasson:
> >>>>>
> >>>>>> Why do you think that static initialization must use a std::mutex
> >>>>>> anyway? ...
> >>>>>
> >>>>> Call it std::mutex or whatever. It is mandated that contenders
> >>>>> are sleeping - that's not possible without sth. else than a mutex.
> >>>>
> >>>> Few dozens posts above I demonstrated an implementation
> >>>> for pre-Vista Windows where contenders are sleeping just fine and
> >>>> waking just fine and initialization of different objects proceeds
> >>>> simultaneously just fine. And it does not use mutex for that.
> >>>> It uses SleepEx() for wait and QueueUserApc() for wakeup.
> >>>
> >>> Why? APC's open up a big can of worms.
> >> Oh shit. I am starting to remember some nightmare code I had to debug
> >> many moon ago that used async cancellation in POSIX threads.
> >>>
> >>>
> >
> > But Windows User APC, at least pre Win11, is async only on issue
> > side. On reception side it is fully synchronous and easy to reason about.
>
> You just need to be in an alterable wait and be ready to handle it.
> Okay. However, fwiw, check out how this following library handles async
> pthread cancellation. Iirc, they used the kernel.
>
> https://sourceware.org/pthreads-win32/
>
> Btw, this lib has been around for a while.
>

Thank you, but I am not going to look at it. Not my area of interest.

>
> > At least it is easy as long as you don't try to enter alertable wait
> > within APC routine, which I don't do. In fact, my APC routine is Nop.
> >
> >>>> It uses one global mutex (in form of critical section) for a short
> >>>> while for metadata updates, but that's done for simplicity and
> >>>> practicality rather than out of necessity. I am pretty sure that
> >>>> with enough effort I can device a variant that achieves the same
> >>>> with CaS.
> >>>
> >>>

Re: Thread-safe initialization of static objects

<uf25ri$39oal$1@dont-email.me>

  copy mid

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

  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 14:12:18 -0700
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <uf25ri$39oal$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <IsoPM.20139$wO91.15127@fx39.iad>
<uelqb1$lo9j$3@dont-email.me> <24DPM.126389$Hih7.28245@fx11.iad>
<uemvt2$rcgo$1@dont-email.me> <ueo915$16kh3$2@dont-email.me>
<ueoqra$19436$2@dont-email.me>
<37dbe3b6-ead0-487b-884c-197124888eben@googlegroups.com>
<uepvs7$1ff81$3@dont-email.me> <ueq0bm$1fihu$2@dont-email.me>
<3ae49bbf-2fb6-47c1-83a6-402cf9656737n@googlegroups.com>
<uf03un$2t2h2$3@dont-email.me>
<f53d5287-5892-4f05-8cf4-02d44c7b417an@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 21:12:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="3465557"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LlUSauxq+AQ/NhcrFpFJCRnvvl5TUdiI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:/p+hjMRnsELib3zJ1Wh/+Qjy70o=
In-Reply-To: <f53d5287-5892-4f05-8cf4-02d44c7b417an@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 27 Sep 2023 21:12 UTC

On 9/27/2023 12:36 AM, Michael S wrote:
> On Wednesday, September 27, 2023 at 5:27:52 AM UTC+3, Chris M. Thomasson wrote:
>> On 9/25/2023 10:20 AM, Michael S wrote:
>>> On Sunday, September 24, 2023 at 9:49:44 PM UTC+3, Chris M. Thomasson wrote:
>>>> On 9/24/2023 11:41 AM, Chris M. Thomasson wrote:
>>>>> On 9/24/2023 2:50 AM, Michael S wrote:
>>>>>> On Sunday, September 24, 2023 at 11:09:31 AM UTC+3, Bonita Montero wrote:
>>>>>>> Am 24.09.2023 um 05:05 schrieb Chris M. Thomasson:
>>>>>>>
>>>>>>>> Why do you think that static initialization must use a std::mutex
>>>>>>>> anyway? ...
>>>>>>>
>>>>>>> Call it std::mutex or whatever. It is mandated that contenders
>>>>>>> are sleeping - that's not possible without sth. else than a mutex.
>>>>>>
>>>>>> Few dozens posts above I demonstrated an implementation
>>>>>> for pre-Vista Windows where contenders are sleeping just fine and
>>>>>> waking just fine and initialization of different objects proceeds
>>>>>> simultaneously just fine. And it does not use mutex for that.
>>>>>> It uses SleepEx() for wait and QueueUserApc() for wakeup.
>>>>>
>>>>> Why? APC's open up a big can of worms.
>>>> Oh shit. I am starting to remember some nightmare code I had to debug
>>>> many moon ago that used async cancellation in POSIX threads.
>>>>>
>>>>>
>>>
>>> But Windows User APC, at least pre Win11, is async only on issue
>>> side. On reception side it is fully synchronous and easy to reason about.
>>
>> You just need to be in an alterable wait and be ready to handle it.
>> Okay. However, fwiw, check out how this following library handles async
>> pthread cancellation. Iirc, they used the kernel.
>>
>> https://sourceware.org/pthreads-win32/
>>
>> Btw, this lib has been around for a while.
>>
>
> Thank you, but I am not going to look at it. Not my area of interest.

No problem. Just remember. When you are _really_ bored with nothing to
do at all... Well, its there. ;^)

>
>>
>>> At least it is easy as long as you don't try to enter alertable wait
>>> within APC routine, which I don't do. In fact, my APC routine is Nop.
>>>
>>>>>> It uses one global mutex (in form of critical section) for a short
>>>>>> while for metadata updates, but that's done for simplicity and
>>>>>> practicality rather than out of necessity. I am pretty sure that
>>>>>> with enough effort I can device a variant that achieves the same
>>>>>> with CaS.
>>>>>
>>>>>

Re: Thread-safe initialization of static objects

<00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:270d:b0:774:2308:eee7 with SMTP id b13-20020a05620a270d00b007742308eee7mr33996qkp.0.1695851313393;
Wed, 27 Sep 2023 14:48:33 -0700 (PDT)
X-Received: by 2002:a05:6830:c8a:b0:6b7:528c:d8bf with SMTP id
bn10-20020a0568300c8a00b006b7528cd8bfmr1768569otb.0.1695851313082; Wed, 27
Sep 2023 14:48:33 -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: Wed, 27 Sep 2023 14:48:32 -0700 (PDT)
In-Reply-To: <ueuj9u$2gdqk$3@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> <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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Wed, 27 Sep 2023 21:48:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 36
 by: Michael S - Wed, 27 Sep 2023 21:48 UTC

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.

Re: Thread-safe initialization of static objects

<uf29ag$3aeta$1@dont-email.me>

  copy mid

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

  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:11:27 -0700
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <uf29ag$3aeta$1@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:11:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3488682"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Q32+bUMDYifLKVywyZTH/93acetgHfog="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:O+ysIoesr4JvlacFsnDHtvRdEzw=
Content-Language: en-US
In-Reply-To: <00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 22:11 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.

Well, shit happens. Yuck.

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

<uf29h6$3afmc$1@dont-email.me>

  copy mid

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

  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:15:02 -0700
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <uf29h6$3afmc$1@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:15:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3489484"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/aNU/yxhQg9niQtP5ugv47iAPLwLdC8Vw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:J+P4L1xAioO04dEB7Vn8SXtMEBA=
In-Reply-To: <00d0c42f-7728-4a7b-9611-3f24f98735ffn@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 27 Sep 2023 22:15 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.

I cannot remember kernel keyed events were implemented in win7, I am
pretty sure they were. Have you ever messed around with those before?

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


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

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor