Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Indecision is the basis of flexibility" -- button at a Science Fiction convention.


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

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

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

<1tzQM.252985$2ph4.238002@fx14.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.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> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<LWINM.13017$ZkX3.12109@fx09.iad> <ue8mn0$q534$4@dont-email.me>
<uY5OM.30730$Yxl8.13078@fx14.iad> <ueb3sb$2638l$6@dont-email.me>
<ZjMOM.9398$EIy4.4982@fx48.iad> <uegsia$3dj0r$2@dont-email.me>
<fp7PM.104556$GHI6.80009@fx17.iad> <uej631$3uji0$4@dont-email.me>
<VnsPM.122464$Hih7.52058@fx11.iad> <uelqeq$lo9j$4@dont-email.me>
<XbJPM.157838$Hih7.40116@fx11.iad> <ueo5ps$163k0$1@dont-email.me>
<Y3_PM.16749$E_d1.14707@fx04.iad> <ueqfec$1i6un$1@dont-email.me>
<mLqQM.164530$1B%c.83768@fx09.iad> <ueu52o$2dv5f$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ueu52o$2dv5f$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 30
Message-ID: <1tzQM.252985$2ph4.238002@fx14.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 26 Sep 2023 07:42:53 -0400
X-Received-Bytes: 2804
 by: Richard Damon - Tue, 26 Sep 2023 11:42 UTC

On 9/26/23 4:34 AM, Bonita Montero wrote:
> Am 26.09.2023 um 03:47 schrieb Pavel:
>
>> On *some* C++ mutex the lock() method might throw. This does not
>> matter because such C++ mutex:
>
> That's enough to expect that to be portable.
>
>> a. does not have to be used for C++ static initialization; ...
>
> I already mentioned that myself, but if there's some other kind of
> mutex this also *may* happen on some platforms. Therefore it should
> be defined this way.
>
>

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.

Why do you keep insisting that the Standard allows sub-standard quality
of operation.

It makes no sense to allow an implementation to use the WRONG type of
mutex for the job, one that can fail, when the right type of
syncronization object exists.

You just want to allow bad implementation, maybe because that is all you
know how to make.

Re: Thread-safe initialization of static objects

<ueuj3l$2gdqk$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 14:33:59 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <ueuj3l$2gdqk$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 12:33:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2635604"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19m0lQH8wz13eKc6ZymgRND9Ow/+IkddEI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:T/ZuSBqsKccaie3qvE8LWvL8B80=
In-Reply-To: <1tzQM.252985$2ph4.238002@fx14.iad>
Content-Language: de-DE
 by: Bonita Montero - Tue, 26 Sep 2023 12:33 UTC

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.

Re: Thread-safe initialization of static objects

<ueuj7i$2gdqk$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 14:36:04 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ueuj7i$2gdqk$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <20230925214046.531@kylheku.com>
<ueu77t$2ebas$1@dont-email.me> <8bzQM.36477$q0k.24969@fx34.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 12:36:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2635604"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PYk+OI9Q90X2vjs1izuRLXxgZ1iGBAhU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6wnlYHJZq08YceT8Hm2hn6pfics=
In-Reply-To: <8bzQM.36477$q0k.24969@fx34.iad>
Content-Language: de-DE
 by: Bonita Montero - Tue, 26 Sep 2023 12:36 UTC

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.

Re: Thread-safe initialization of static objects

<ueuj9u$2gdqk$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 14:37:19 +0200
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ueuj9u$2gdqk$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 12:37:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2635604"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kVmyqn4ug69tAX5wx0zmkIH1suwOrD8Q="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zf0n50nz2koq1tUdxc8UD4APjD8=
In-Reply-To: <3bzQM.36476$q0k.14387@fx34.iad>
Content-Language: de-DE
 by: Bonita Montero - Tue, 26 Sep 2023 12:37 UTC

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.

Re: Thread-safe initialization of static objects

<xHCQM.35599$ugs.5613@fx36.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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>
Lines: 9
Message-ID: <xHCQM.35599$ugs.5613@fx36.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 26 Sep 2023 15:23:09 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 26 Sep 2023 15:23:09 GMT
X-Received-Bytes: 1414
 by: Scott Lurndal - Tue, 26 Sep 2023 15:23 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>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.

No, it is not.

Re: Thread-safe initialization of static objects

<eJCQM.35600$ugs.8334@fx36.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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>
Lines: 14
Message-ID: <eJCQM.35600$ugs.8334@fx36.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 26 Sep 2023 15:24:58 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 26 Sep 2023 15:24:58 GMT
X-Received-Bytes: 1675
 by: Scott Lurndal - Tue, 26 Sep 2023 15:24 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>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.

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.

Re: Thread-safe initialization of static objects

<8KCQM.35601$ugs.6585@fx36.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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>
Lines: 12
Message-ID: <8KCQM.35601$ugs.6585@fx36.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 26 Sep 2023 15:25:56 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 26 Sep 2023 15:25:56 GMT
X-Received-Bytes: 1675
 by: Scott Lurndal - Tue, 26 Sep 2023 15:25 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>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.

No, there is no delayed initialization with pthread mutexes.

Re: Thread-safe initialization of static objects

<ueutfg$2ihvn$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 17:30:56 +0200
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <ueutfg$2ihvn$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 15:30:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2705399"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19o+XbIs0MxbipTSkIkG9Wuz6aK4rQwC4g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8ttgyPxpVvX8Pez8i9uUZ+b9ZGE=
Content-Language: de-DE
In-Reply-To: <8KCQM.35601$ugs.6585@fx36.iad>
 by: Bonita Montero - Tue, 26 Sep 2023 15:30 UTC

Am 26.09.2023 um 17:25 schrieb Scott Lurndal:

> No, there is no delayed initialization with pthread mutexes.

There must be since you can't create a semaphore by pure assignment.

Re: Thread-safe initialization of static objects

<ueutgq$2ii89$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 17:31:37 +0200
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <ueutgq$2ii89$1@dont-email.me>
References: <udafjf$2joeq$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> <xHCQM.35599$ugs.5613@fx36.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 15:31:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2705673"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yn+DZ23wykn8maiD/eyjbH5P50Pza0Mo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:SRmEPISG2QsmSlRtTYpFNq3qDDY=
Content-Language: de-DE
In-Reply-To: <xHCQM.35599$ugs.5613@fx36.iad>
 by: Bonita Montero - Tue, 26 Sep 2023 15:31 UTC

Am 26.09.2023 um 17:23 schrieb Scott Lurndal:

> No, it is not.

What else ?

Re: Thread-safe initialization of static objects

<ueutjo$2ii89$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 17:33:12 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ueutjo$2ii89$2@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 15:33:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2705673"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jItqInkyZeicZQ7W2VzT7TCn1eOUN+uQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:C7XenMu0Tow6aRIuxGnowWx3u6I=
In-Reply-To: <eJCQM.35600$ugs.8334@fx36.iad>
Content-Language: de-DE
 by: Bonita Montero - Tue, 26 Sep 2023 15:33 UTC

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.

Re: Thread-safe initialization of static objects

<18c909bc-a09f-46e2-af03-a41dc071d73en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:3d10:b0:774:20d6:6b8d with SMTP id tq16-20020a05620a3d1000b0077420d66b8dmr84122qkn.13.1695743544040;
Tue, 26 Sep 2023 08:52:24 -0700 (PDT)
X-Received: by 2002:a4a:dccc:0:b0:57b:ee95:ad48 with SMTP id
h12-20020a4adccc000000b0057bee95ad48mr846877oou.0.1695743543724; Tue, 26 Sep
2023 08:52:23 -0700 (PDT)
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!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 08:52:23 -0700 (PDT)
In-Reply-To: <ueutfg$2ihvn$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <udafjf$2joeq$1@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <18c909bc-a09f-46e2-af03-a41dc071d73en@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Tue, 26 Sep 2023 15:52:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2658
 by: Michael S - Tue, 26 Sep 2023 15:52 UTC

On Tuesday, September 26, 2023 at 6:31:13 PM UTC+3, Bonita Montero wrote:
> Am 26.09.2023 um 17:25 schrieb Scott Lurndal:
>
> > No, there is no delayed initialization with pthread mutexes.
> There must be since you can't create a semaphore by pure assignment.

I don't know how it works for pthread mutexes on any possible OS
that supports pthreads.
But I do know that Windows SRW Lock can be initialized statically.
Also I do know that it does not have to be destroyed. As long
as no threads are locked on it, it can be simply abandoned.

https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initializesrwlock
"An unlocked SRW lock with no waiting threads is in its initial state and can be copied,
moved, and forgotten without being explicitly destroyed."

Which is a very strong hint that there is no hidden kernel object per
lock behind the scene. And very likely no hidden kernel object per any
fixed number of SRW locks.

Re: Thread-safe initialization of static objects

<e01f389c-3f23-47dc-89cd-a21038c6592an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:948d:b0:772:6373:5a1b with SMTP id sn13-20020a05620a948d00b0077263735a1bmr72136qkn.2.1695744315523;
Tue, 26 Sep 2023 09:05:15 -0700 (PDT)
X-Received: by 2002:a05:6808:2391:b0:3ae:2b19:c1ce with SMTP id
bp17-20020a056808239100b003ae2b19c1cemr5417168oib.8.1695744315254; Tue, 26
Sep 2023 09:05:15 -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 09:05:14 -0700 (PDT)
In-Reply-To: <uetrjn$2car5$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <udafjf$2joeq$1@dont-email.me> <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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e01f389c-3f23-47dc-89cd-a21038c6592an@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Tue, 26 Sep 2023 16:05:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 6739
 by: Michael S - Tue, 26 Sep 2023 16:05 UTC

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.

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

Re: Thread-safe initialization of static objects

<ueuvlp$2ivla$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 18:08:25 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ueuvlp$2ivla$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 16:08:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2719402"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18X9EUJPyfiCM+k4WaYTdN2tzn6dNfLz0g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:L8AZa42Ym764y4M9yCv1JH8oJdQ=
Content-Language: de-DE
In-Reply-To: <18c909bc-a09f-46e2-af03-a41dc071d73en@googlegroups.com>
 by: Bonita Montero - Tue, 26 Sep 2023 16:08 UTC

Am 26.09.2023 um 17:52 schrieb Michael S:

> I don't know how it works for pthread mutexes ...

LOL

> But I do know that Windows SRW Lock can be initialized statically.

Maybe, but this is also possible with delayed initialization.

Re: Thread-safe initialization of static objects

<20230926094053.617@kylheku.com>

  copy mid

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

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

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

If you're betting your business on writing some multithreading
application for a platform, you should know what actually happens on
the platform.

You probably don't choose a platform where mutexes require resources
that are only allocated on lock contention, and which can then blow up.

If you do choose that platform, you have some plan. You identify under
which conditions such a problem happens. Perhaps the system can be
configured to minimize the risk. Or perhasps there are warning signs,
like low memory, so that evasive action can be taken: clean shutdown and
restart.

Memory overcommit is enabled on most GNU/Linux system installations.
This means that memory allocations can fail not when you allocate
the memory (e.g. mmap() returning MAP_FAILED or malloc returning null)
but when you try to access the memory.

You don't necessarily combat this in the application code. Ways to deal
with it range from reducing or disabling overcommit, to just having
enough swap space for a soft landing: evasive action taken when the
system shows signs of thrashing.

Most programs at most check for up-front allocator failure; most are not
prepared to handle an access violation upon using the result of a
successful-looking allocation.

Assuming you have some mutex type which is "overcommitted" similarly,
similar reasoning applies.

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

<uev2c6$2je12$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 18:54:30 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <uev2c6$2je12$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <20230926094053.617@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 16:54:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2734114"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PmwFWSvL+dmfQqtAdmeqioiATDd1Fkpk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:bm4M4jqw//T6yam7vMqqperW478=
In-Reply-To: <20230926094053.617@kylheku.com>
Content-Language: de-DE
 by: Bonita Montero - Tue, 26 Sep 2023 16:54 UTC

Am 26.09.2023 um 18:46 schrieb Kaz Kylheku:

> You probably don't choose a platform where mutexes require resources
> that are only allocated on lock contention, and which can then blow up.

Contention is always possible and always expensive.

> Memory overcommit is enabled on most GNU/Linux system installations.
> This means that memory allocations can fail not when you allocate
> the memory (e.g. mmap() returning MAP_FAILED or malloc returning null)
> but when you try to access the memory.

Memory overcommit partitially bases on swappable memory. Seamphores are
in non-pageable memory inside the kernel. But I accept what you mean: if
you accept that an application can suddenly terminate because of the OOM
killer you also might accept that it would be terminated because a sin-
gle kernel semaphore coudn't be created. That may be acceptable for most
users but if there's an error code from the kernel this still should be
forwarded through your runtime for those who coudln't accept that.

Re: Thread-safe initialization of static objects

<9bd2422d-f363-47b3-a01e-256d228c59bcn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:3282:b0:65b:22e0:c3b7 with SMTP id mu2-20020a056214328200b0065b22e0c3b7mr28428qvb.9.1695747649548;
Tue, 26 Sep 2023 10:00:49 -0700 (PDT)
X-Received: by 2002:a05:6870:1a91:b0:1d6:aa05:c733 with SMTP id
ef17-20020a0568701a9100b001d6aa05c733mr4577906oab.5.1695747649321; Tue, 26
Sep 2023 10:00:49 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!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: Tue, 26 Sep 2023 10:00:48 -0700 (PDT)
In-Reply-To: <ueuvlp$2ivla$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <udafjf$2joeq$1@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9bd2422d-f363-47b3-a01e-256d228c59bcn@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Tue, 26 Sep 2023 17:00:49 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 11
 by: Michael S - Tue, 26 Sep 2023 17:00 UTC

On Tuesday, September 26, 2023 at 7:08:43 PM UTC+3, Bonita Montero wrote:
> Am 26.09.2023 um 17:52 schrieb Michael S:
>
> > I don't know how it works for pthread mutexes ...
>
> LOL
> > But I do know that Windows SRW Lock can be initialized statically.
> Maybe, but this is also possible with delayed initialization.

If you were reading my post up to the end you were understanding that
such possibility is extremely low.

Re: Thread-safe initialization of static objects

<20230926095933.402@kylheku.com>

  copy mid

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

  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 17:01:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <20230926095933.402@kylheku.com>
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>
Injection-Date: Tue, 26 Sep 2023 17:01:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="84073cef60c20381e418356514cfa3d7";
logging-data="2731336"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bKa2ynytX9w3cltiNw7PEf48x5eCPdQc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:hRrfHpb4WIty3bI9LulJsJ4s6zw=
 by: Kaz Kylheku - Tue, 26 Sep 2023 17:01 UTC

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.

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

<464f65ba-0d1a-4a22-bb39-ca559d65e574n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:ab3:b0:655:babe:b3f8 with SMTP id ew19-20020a0562140ab300b00655babeb3f8mr41371qvb.3.1695747878649;
Tue, 26 Sep 2023 10:04:38 -0700 (PDT)
X-Received: by 2002:a05:6808:15a9:b0:3ad:29a4:f542 with SMTP id
t41-20020a05680815a900b003ad29a4f542mr1786192oiw.5.1695747878497; Tue, 26 Sep
2023 10:04:38 -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 10:04:38 -0700 (PDT)
In-Reply-To: <9bd2422d-f363-47b3-a01e-256d228c59bcn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <udafjf$2joeq$1@dont-email.me> <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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <464f65ba-0d1a-4a22-bb39-ca559d65e574n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Tue, 26 Sep 2023 17:04:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2453
 by: Michael S - Tue, 26 Sep 2023 17:04 UTC

On Tuesday, September 26, 2023 at 8:01:00 PM UTC+3, Michael S wrote:
> On Tuesday, September 26, 2023 at 7:08:43 PM UTC+3, Bonita Montero wrote:
> > Am 26.09.2023 um 17:52 schrieb Michael S:
> >
> > > I don't know how it works for pthread mutexes ...
> >
> > LOL
> > > But I do know that Windows SRW Lock can be initialized statically.
> > Maybe, but this is also possible with delayed initialization.
> If you were reading my post up to the end you were understanding that
> such possibility is extremely low.

I meant to write 'extremely unlikely'.

Re: Thread-safe initialization of static objects

<20230926100151.733@kylheku.com>

  copy mid

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

  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 17:09:42 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20230926100151.733@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>
Injection-Date: Tue, 26 Sep 2023 17:09:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="84073cef60c20381e418356514cfa3d7";
logging-data="2731336"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Gw2Cpx8P2NJ9fEOzvF7jpN11pvoMQaD0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:LJe2Toyiz86IhZ392ZiacepyFpI=
 by: Kaz Kylheku - Tue, 26 Sep 2023 17:09 UTC

On 2023-09-26, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 26.09.2023 um 17:25 schrieb Scott Lurndal:
>
>> No, there is no delayed initialization with pthread mutexes.
>
> There must be since you can't create a semaphore by pure assignment.

It has already been explained that there are multiple ways to implement
mutexes.

The approach which requires a kernel semaphore handle to be allocated
is a possibility. It would be difficult under POSIX because the
static initializer will not do that, and the lock operation is not
described as returning a resource-related error code.

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.

The NPTL rewrite of the treading library was accompanied by futexes
in the kernel. Futexes also don't require allocation. Any memory
location in your virtual space can be used as a futex without any
resources being registered. Futexes were designed that way specifically
in order not to have mutex initialization fail on resource acquisition,
or waste time in the kernel, so that mutexes can be cheaply and safely.

Futexes use a fixed pool of wait queues which is allocated upfront. The
memory location is hashed to a wait queue, which it possibly shares with
unrelated futexes due to hash collisions.

There is no reason for any commercial, proprietary platform to do worse
than open source did twenty years ago, or for anyone to use it if it
sodes.

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

<BiEQM.286107$%uv8.162186@fx15.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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>
Lines: 21
Message-ID: <BiEQM.286107$%uv8.162186@fx15.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 26 Sep 2023 17:13:05 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 26 Sep 2023 17:13:05 GMT
X-Received-Bytes: 2030
 by: Scott Lurndal - Tue, 26 Sep 2023 17:13 UTC

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.

Re: Thread-safe initialization of static objects

<uev4fr$2jugo$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 19:30:35 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <uev4fr$2jugo$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 17:30:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2751000"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18k75kO5fgceVMHxzbXt9NhzP/I9qrFGow="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:sat3VSDNsfTpEMZM4kju25UY6S8=
Content-Language: de-DE
In-Reply-To: <9bd2422d-f363-47b3-a01e-256d228c59bcn@googlegroups.com>
 by: Bonita Montero - Tue, 26 Sep 2023 17:30 UTC

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.

Re: Thread-safe initialization of static objects

<uev4kk$2jugo$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 26 Sep 2023 19:33:08 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <uev4kk$2jugo$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Sep 2023 17:33:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5bb0134c85af7d68e28a6d0cb985b1dc";
logging-data="2751000"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GIcKKlqpWGFyUljIKA+/6WMbXAdNIIl4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:AJhZj47ZHU3ggpbgZyfnTbAjvTg=
Content-Language: de-DE
In-Reply-To: <20230926100151.733@kylheku.com>
 by: Bonita Montero - Tue, 26 Sep 2023 17:33 UTC

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.

Re: Thread-safe initialization of static objects

<uevd5n$2ligo$1@dont-email.me>

  copy mid

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

  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 12:58:43 -0700
Organization: A noiseless patient Spider
Lines: 106
Message-ID: <uevd5n$2ligo$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Sep 2023 19:58:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2804248"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iw4d4av3qJJiZgKS4AuEfdomNtZ9fM30="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:sioGbhAvHdMUKbpzpeenarU1a80=
In-Reply-To: <e01f389c-3f23-47dc-89cd-a21038c6592an@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 19:58 UTC

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.

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

<uevdbr$2ligo$2@dont-email.me>

  copy mid

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

  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:02:02 -0700
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <uevdbr$2ligo$2@dont-email.me>
References: <udafjf$2joeq$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> <xHCQM.35599$ugs.5613@fx36.iad>
<ueutgq$2ii89$1@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:02:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2804248"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18i7caMDJCxFnNCB7lzPDb4Or8ZTLFbL1c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:/DcrM72XAVVH7sSAeZ5UBOhRV5k=
In-Reply-To: <ueutgq$2ii89$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 20:02 UTC

On 9/26/2023 8:31 AM, Bonita Montero wrote:
> Am 26.09.2023 um 17:23 schrieb Scott Lurndal:
>
>> No, it is not.
>
> What else ?
>

Sigh.

Re: Thread-safe initialization of static objects

<uevdh3$2ligo$3@dont-email.me>

  copy mid

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

  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:04:50 -0700
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <uevdh3$2ligo$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me> <ZjMOM.9398$EIy4.4982@fx48.iad>
<uegsia$3dj0r$2@dont-email.me> <fp7PM.104556$GHI6.80009@fx17.iad>
<uej631$3uji0$4@dont-email.me> <mzkPM.16155$ugs.3977@fx36.iad>
<uekler$bqj8$1@dont-email.me> <20230922111441.730@kylheku.com>
<uelq9h$lo9j$2@dont-email.me> <20230923041951.728@kylheku.com>
<uemlbj$pl2d$1@dont-email.me> <20230923185708.811@kylheku.com>
<ueoqpa$19436$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <20230925214046.531@kylheku.com>
<ueu77t$2ebas$1@dont-email.me> <8bzQM.36477$q0k.24969@fx34.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:04:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="196fae80d8a93b5feca968dadd2c090d";
logging-data="2804248"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iBDQA4CmiJ4WnIeBhxpCtAT381kPq2qY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:GcgUWxHrUSj0lQD5JlrrZu9fRQc=
In-Reply-To: <8bzQM.36477$q0k.24969@fx34.iad>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 26 Sep 2023 20:04 UTC

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

Bonita needs to learn that there are ways to, do it right. For some damn
reason, it reminds me of the following crazy song from Daft Punk.
Actually, Daft Punk reminds me of Bonita for some strange reason... Robots?

https://youtu.be/LL-gyhZVvx0

Everybody will be dancing when we are doing it right...

;^)

>
> Thus, doing something that might fail is just wrong.
>
> You seem to like failing at what you try to do.


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

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor