Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Remember Darwin; building a better mousetrap merely results in smarter mice.


devel / comp.lang.c++ / Re: Run this under Windows and Linux

SubjectAuthor
* Run this under Windows and LinuxBonita Montero
+* Re: Run this under Windows and LinuxChris M. Thomasson
|`* Re: Run this under Windows and LinuxBonita Montero
| +- Re: Run this under Windows and LinuxBranimir Maksimovic
| `* Re: Run this under Windows and LinuxChris M. Thomasson
|  +* Re: Run this under Windows and LinuxBonita Montero
|  |+* Re: Run this under Windows and LinuxBonita Montero
|  ||+* Re: Run this under Windows and LinuxBonita Montero
|  |||`* Re: Run this under Windows and LinuxScott Lurndal
|  ||| `* Re: Run this under Windows and LinuxBonita Montero
|  |||  `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |||   `* Re: Run this under Windows and LinuxBonita Montero
|  |||    `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |||     +* Re: Run this under Windows and LinuxChris M. Thomasson
|  |||     |+- Re: Run this under Windows and LinuxBonita Montero
|  |||     |`* Re: Run this under Windows and LinuxScott Lurndal
|  |||     | +- Re: Run this under Windows and LinuxBonita Montero
|  |||     | `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |||     |  `- Re: Run this under Windows and LinuxChris M. Thomasson
|  |||     `* Re: Run this under Windows and LinuxScott Lurndal
|  |||      +* Re: Run this under Windows and LinuxChris M. Thomasson
|  |||      |`- Re: Run this under Windows and LinuxChris M. Thomasson
|  |||      `* Re: Run this under Windows and LinuxBonita Montero
|  |||       `- Re: Run this under Windows and LinuxChris M. Thomasson
|  ||+* Re: Run this under Windows and LinuxChris M. Thomasson
|  |||`- Re: Run this under Windows and LinuxBonita Montero
|  ||+* Re: Run this under Windows and LinuxKaz Kylheku
|  |||+- Re: Run this under Windows and LinuxChris M. Thomasson
|  |||`- Re: Run this under Windows and LinuxChris M. Thomasson
|  ||`* Re: Run this under Windows and LinuxMichael S
|  || `* Re: Run this under Windows and LinuxBonita Montero
|  ||  `- Re: Run this under Windows and LinuxChris M. Thomasson
|  |`* Re: Run this under Windows and LinuxChris M. Thomasson
|  | `* Re: Run this under Windows and LinuxBonita Montero
|  |  +* Re: Run this under Windows and LinuxScott Lurndal
|  |  |+* Re: Run this under Windows and LinuxDavid Brown
|  |  ||+- Re: Run this under Windows and LinuxBonita Montero
|  |  ||`* Re: Run this under Windows and LinuxChris M. Thomasson
|  |  || `* Re: Run this under Windows and LinuxDavid Brown
|  |  ||  +- Re: Run this under Windows and LinuxChris M. Thomasson
|  |  ||  `- Re: Run this under Windows and LinuxChris M. Thomasson
|  |  |`* Re: Run this under Windows and LinuxBonita Montero
|  |  | `* Re: Run this under Windows and LinuxKaz Kylheku
|  |  |  `* Re: Run this under Windows and LinuxMichael S
|  |  |   `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |  |    `- Re: Run this under Windows and LinuxKaz Kylheku
|  |  `* Re: Run this under Windows and LinuxKaz Kylheku
|  |   `* Re: Run this under Windows and LinuxBonita Montero
|  |    `* Re: Run this under Windows and LinuxKaz Kylheku
|  |     +* Re: Run this under Windows and LinuxBonita Montero
|  |     |`* Re: Run this under Windows and LinuxDavid Brown
|  |     | `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  +* Re: Run this under Windows and LinuxDavid Brown
|  |     |  |`* Re: Run this under Windows and LinuxBonita Montero
|  |     |  | `* Re: Run this under Windows and LinuxDavid Brown
|  |     |  |  `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   +* Re: Run this under Windows and LinuxDavid Brown
|  |     |  |   |+* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   ||+- Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |   ||+- Re: Run this under Windows and LinuxScott Lurndal
|  |     |  |   ||+- Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  |   ||`* Re: Run this under Windows and LinuxDavid Brown
|  |     |  |   || `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   ||  `* Re: Run this under Windows and LinuxDavid Brown
|  |     |  |   ||   `- Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   |+- Re: Run this under Windows and LinuxScott Lurndal
|  |     |  |   |`- Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  |   +* Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |   |`* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   | +* Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |   | |`* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   | | `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   | |  `- Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  |   | `* Re: Run this under Windows and LinuxScott Lurndal
|  |     |  |   |  `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   |   `* Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |   |    `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   |     +* Re: Run this under Windows and LinuxScott Lurndal
|  |     |  |   |     |`- Re: Run this under Windows and LinuxBonita Montero
|  |     |  |   |     `- Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |   `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  |    +- Re: Run this under Windows and LinuxBonita Montero
|  |     |  |    `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |     `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  |      +* Re: Run this under Windows and LinuxBonita Montero
|  |     |  |      |`* Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  |      | `* Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |      |  `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  |      |   `- Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |      `- Re: Run this under Windows and LinuxBonita Montero
|  |     |  +* Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |`- Re: Run this under Windows and LinuxDavid Brown
|  |     |  +* Re: Run this under Windows and LinuxScott Lurndal
|  |     |  |+* Re: Run this under Windows and LinuxBonita Montero
|  |     |  ||`* Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  || `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  ||  `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  ||   `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  ||    `* Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  ||     `* Re: Run this under Windows and LinuxBonita Montero
|  |     |  ||      +* Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  ||      `* Re: Run this under Windows and LinuxKaz Kylheku
|  |     |  |`- Re: Run this under Windows and LinuxChris M. Thomasson
|  |     |  `* Re: Run this under Windows and LinuxChris M. Thomasson
|  |     `- Re: Run this under Windows and LinuxChris M. Thomasson
|  `* Re: Run this under Windows and LinuxBonita Montero
`* Re: Run this under Windows and LinuxBranimir Maksimovic

Pages:1234567
Re: Run this under Windows and Linux

<ui3aob$2sa5j$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 18:30:55 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <ui3aob$2sa5j$1@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Nov 2023 17:30:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="080e5ea4d61a2409bab2c11b4b283d95";
logging-data="3025075"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zKxL6a5Osj0vGaLyQqByIwSmre9DACy8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hqPNaSxN+WpEwHLtmje1Fwyxeic=
Content-Language: de-DE
In-Reply-To: <20231103102128.731@kylheku.com>
 by: Bonita Montero - Fri, 3 Nov 2023 17:30 UTC

Am 03.11.2023 um 18:28 schrieb Kaz Kylheku:

> That depends entirely on which kind of mutex on what platform.
>
> - POSIX mutexes make that either an error, or undefined behavior,
> depending on the mutex attributes.
>
> - MSDN says this about critical sections: "If a thread calls
> LeaveCriticalSection when it does not have ownership of the specified
> critical section object, an error occurs that may cause another thread
> using EnterCriticalSection to wait indefinitely."
>
> - MSDN, again, about Win32 mutex objects: "The ReleaseMutex function
> fails if the calling thread does not own the mutex object."
>
> - ISO C (since C11) mtx_unlock: undefined behavior if mutex is not
> locked by the calling thread.
>
> - C++ std::mutex::unlock: ditto.
>
> At this point, I'm already well into stuff I don't give a shit about,
> to look for more. I don't care if ScrotelyOS developed in Ruritania
> between 1973 and 1981 had "mutexes" that had up to three owners.

The discussed benaphore allows this.

Re: Run this under Windows and Linux

<20231103105439.435@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 18:03:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <20231103105439.435@kylheku.com>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com>
<ui3aob$2sa5j$1@dont-email.me>
Injection-Date: Fri, 3 Nov 2023 18:03:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2e148673ec60bf6f5c0bc2f39a587be1";
logging-data="3033733"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HdM/7F1aZmAzZbbzTJTKKpnp8DseOqT8="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:6kXiTMCnFu8E80BOMGYUDtTOx3o=
 by: Kaz Kylheku - Fri, 3 Nov 2023 18:03 UTC

On 2023-11-03, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 03.11.2023 um 18:28 schrieb Kaz Kylheku:
>
>> That depends entirely on which kind of mutex on what platform.
>>
>> - POSIX mutexes make that either an error, or undefined behavior,
>> depending on the mutex attributes.
>>
>> - MSDN says this about critical sections: "If a thread calls
>> LeaveCriticalSection when it does not have ownership of the specified
>> critical section object, an error occurs that may cause another thread
>> using EnterCriticalSection to wait indefinitely."
>>
>> - MSDN, again, about Win32 mutex objects: "The ReleaseMutex function
>> fails if the calling thread does not own the mutex object."
>>
>> - ISO C (since C11) mtx_unlock: undefined behavior if mutex is not
>> locked by the calling thread.
>>
>> - C++ std::mutex::unlock: ditto.
>>
>> At this point, I'm already well into stuff I don't give a shit about,
>> to look for more. I don't care if ScrotelyOS developed in Ruritania
>> between 1973 and 1981 had "mutexes" that had up to three owners.
>
> The discussed benaphore allows this.

That's a kind of semaphore, and its name reflects that.

Benoit Schillings introduced this word as an optimization that is
for certain inefficient semaphore implementations:

https://www.haiku-os.org/legacy-docs/benewsletter/Issue1-26.html#Engineering1-26

He recommends this:

void acquire_benaphore()
{
long previous_value;
previous_value = atomic_add (&benaphore_atom, 1);

if (previous_value > 0)
acquire_sem(benaphore_sem);
}

Firstly, this is not a mutex but a semaphore. Secondly, it only makes
sense if acquire_sem is somehow expensive (like a trap to the kernel).

The reason is that acquire_sem already looks like acquire_benaphore:

void acquire_sem(semaphore *s)
{
long prev = atomic_add(&s->counter);

if (prev > 0) {
// suspend caller somehow
}

// ...

}

--
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: Run this under Windows and Linux

<ui3csi$2sm3u$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 19:07:18 +0100
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <ui3csi$2sm3u$1@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com>
<ui3aob$2sa5j$1@dont-email.me> <20231103105439.435@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Nov 2023 18:07:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="080e5ea4d61a2409bab2c11b4b283d95";
logging-data="3037310"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19umhH9cjiP8+g8fP2YF15rSUQ9tlctN2o="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hrn/N3+YSQS+w6dbcypgrrPZ82M=
Content-Language: de-DE
In-Reply-To: <20231103105439.435@kylheku.com>
 by: Bonita Montero - Fri, 3 Nov 2023 18:07 UTC

Am 03.11.2023 um 19:03 schrieb Kaz Kylheku:
> On 2023-11-03, Bonita Montero <Bonita.Montero@gmail.com> wrote:

>> Am 03.11.2023 um 18:28 schrieb Kaz Kylheku:

>> The discussed benaphore allows this.

> That's a kind of semaphore, and its name reflects that.

It's a mutex, look at the code.
And look at the discussion on stack overflow about that:
https://stackoverflow.com/questions/1635416/are-benaphores-worth-implementing-on-modern-oss

Re: Run this under Windows and Linux

<ui3cvg$2sngu$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 19:08:51 +0100
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ui3cvg$2sngu$1@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com>
<ui3aob$2sa5j$1@dont-email.me> <20231103105439.435@kylheku.com>
<ui3csi$2sm3u$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Nov 2023 18:08:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="080e5ea4d61a2409bab2c11b4b283d95";
logging-data="3038750"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FZ4TH/pkZUqeIwecqp95blLRHMFWTFZ8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UdYEUe8XdJ3uUwQsT8y0eqdlvnE=
Content-Language: de-DE
In-Reply-To: <ui3csi$2sm3u$1@dont-email.me>
 by: Bonita Montero - Fri, 3 Nov 2023 18:08 UTC

Am 03.11.2023 um 19:07 schrieb Bonita Montero:

> It's a mutex, look at the code.
> And look at the discussion on stack overflow about that:
> https://stackoverflow.com/questions/1635416/are-benaphores-worth-implementing-on-modern-oss

And this article also refers to it as a mutex:
https://preshing.com/20120226/roll-your-own-lightweight-mutex/

Re: Run this under Windows and Linux

<7jb1N.177700$sxoa.38730@fx13.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!paganini.bofh.team!2.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Run this under Windows and Linux
Newsgroups: comp.lang.c++
References: <uhnl0h$bm9a$1@dont-email.me> <uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me> <uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com> <ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com> <ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me> <ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me> <ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me> <ui34r0$2r7cc$1@dont-email.me> <ui393f$2s0sv$1@dont-email.me>
Lines: 43
Message-ID: <7jb1N.177700$sxoa.38730@fx13.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 03 Nov 2023 18:51:47 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 03 Nov 2023 18:51:47 GMT
X-Received-Bytes: 2711
 by: Scott Lurndal - Fri, 3 Nov 2023 18:51 UTC

David Brown <david.brown@hesbynett.no> writes:
>On 03/11/2023 16:49, Bonita Montero wrote:
>> Am 03.11.2023 um 16:35 schrieb David Brown:
>>
>>> And using the definitions held by most people involved (including the
>>> C++ standard library, the Windows API, and AFAIK POSIX), mutexes have
>>> ownership and semaphores do not. ...
>>
>> Mutexes only have ownership if they're recursive. Otherwise you
>> can easily unlock a mutex which was locked in another thread.
>>
>
>Please read <https://en.cppreference.com/w/cpp/thread/mutex/unlock>.
>Note the sentence "The mutex must be locked by the current thread of
>execution, otherwise, the behavior is undefined."
>
>Please read the C++ standards, section [thread.mutex.requirements.mutex]
>and note that for "unlock()", there is the sentence "Preconditions: The
>calling thread owns the mutex."
>

And read the POSIX standard as well.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html

>Please learn what "undefined behaviour" means, and what "preconditions"
>mean.
>
>Then come back and apologise.
>
>>> A semaphore is not a lock, ...
>>
>> It can be used as a lock although it is not recommended because
>> a semaphore is usually a pure kernel facility.
>>
>
>Using a semaphore as a lock is not recommended because a semaphore does
>not make a good lock. A main reason for that is that it has no concept
>of ownership. /All/ locking and inter-thread signalling mechanisms rely
>on kernel facilities, because they need to be able to sleep, and to wake
>sleeping threads.
>
>

Re: Run this under Windows and Linux

<3kb1N.177701$sxoa.81181@fx13.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Run this under Windows and Linux
Newsgroups: comp.lang.c++
References: <uhnl0h$bm9a$1@dont-email.me> <uhual7$1omhf$4@dont-email.me> <uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com> <ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com> <ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me> <ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me> <ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me> <ui34r0$2r7cc$1@dont-email.me> <ui393f$2s0sv$1@dont-email.me> <ui39dr$2s28j$1@dont-email.me>
Lines: 15
Message-ID: <3kb1N.177701$sxoa.81181@fx13.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 03 Nov 2023 18:52:47 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 03 Nov 2023 18:52:47 GMT
X-Received-Bytes: 1582
 by: Scott Lurndal - Fri, 3 Nov 2023 18:52 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 03.11.2023 um 18:02 schrieb David Brown:
>
>> Please read <https://en.cppreference.com/w/cpp/thread/mutex/unlock>.
>> Note the sentence "The mutex must be locked by the current thread of
>> execution, otherwise, the behavior is undefined."
>
>Maybe, but I'm talking about how mutexes usually work internally.

Why does that matter? It's the behavior seen by the code
using the mutex that matters.

Undefined behavior isn't something an application can rely on.

You keep digging yourself deeper and deeper.

Re: Run this under Windows and Linux

<zlb1N.177702$sxoa.164234@fx13.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Run this under Windows and Linux
Newsgroups: comp.lang.c++
References: <uhnl0h$bm9a$1@dont-email.me> <uhual7$1omhf$4@dont-email.me> <uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com> <ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com> <ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me> <ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me> <ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me> <ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com> <ui3aob$2sa5j$1@dont-email.me>
Lines: 30
Message-ID: <zlb1N.177702$sxoa.164234@fx13.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 03 Nov 2023 18:54:23 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 03 Nov 2023 18:54:23 GMT
X-Received-Bytes: 2234
 by: Scott Lurndal - Fri, 3 Nov 2023 18:54 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 03.11.2023 um 18:28 schrieb Kaz Kylheku:
>
>> That depends entirely on which kind of mutex on what platform.
>>
>> - POSIX mutexes make that either an error, or undefined behavior,
>> depending on the mutex attributes.
>>
>> - MSDN says this about critical sections: "If a thread calls
>> LeaveCriticalSection when it does not have ownership of the specified
>> critical section object, an error occurs that may cause another thread
>> using EnterCriticalSection to wait indefinitely."
>>
>> - MSDN, again, about Win32 mutex objects: "The ReleaseMutex function
>> fails if the calling thread does not own the mutex object."
>>
>> - ISO C (since C11) mtx_unlock: undefined behavior if mutex is not
>> locked by the calling thread.
>>
>> - C++ std::mutex::unlock: ditto.
>>
>> At this point, I'm already well into stuff I don't give a shit about,
>> to look for more. I don't care if ScrotelyOS developed in Ruritania
>> between 1973 and 1981 had "mutexes" that had up to three owners.
>
>The discussed benaphore allows this.

And which operating system offers this soi disant 'benaphore' as a
synchronization mechanism?

Re: Run this under Windows and Linux

<ui3hec$2th64$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 20:25:04 +0100
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ui3hec$2th64$1@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com>
<ui3aob$2sa5j$1@dont-email.me> <zlb1N.177702$sxoa.164234@fx13.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Nov 2023 19:25:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="080e5ea4d61a2409bab2c11b4b283d95";
logging-data="3065028"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PjSdfszkCyorrHOeCOocnKNG6qmFZlz8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:og3/n00eW5I2SpLkz+A1cYdeK+c=
In-Reply-To: <zlb1N.177702$sxoa.164234@fx13.iad>
Content-Language: de-DE
 by: Bonita Montero - Fri, 3 Nov 2023 19:25 UTC

Am 03.11.2023 um 19:54 schrieb Scott Lurndal:

> And which operating system offers this soi disant 'benaphore' as a
> synchronization mechanism?

Non-recursive mutexes mostly base on the same mechanisms since
an atomic add doesn't need looping.

Re: Run this under Windows and Linux

<20231103135319.1@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 20:56:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <20231103135319.1@kylheku.com>
References: <uhnl0h$bm9a$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com>
<ui3aob$2sa5j$1@dont-email.me> <zlb1N.177702$sxoa.164234@fx13.iad>
<ui3hec$2th64$1@dont-email.me>
Injection-Date: Fri, 3 Nov 2023 20:56:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2e148673ec60bf6f5c0bc2f39a587be1";
logging-data="3094484"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/51kEm77tiRP4YX4dhbJWhitvoMsNdt7c="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:zXRrT644DAAvZ1HwzTUp2Wzlbr0=
 by: Kaz Kylheku - Fri, 3 Nov 2023 20:56 UTC

On 2023-11-03, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 03.11.2023 um 19:54 schrieb Scott Lurndal:
>
>> And which operating system offers this soi disant 'benaphore' as a
>> synchronization mechanism?
>
> Non-recursive mutexes mostly base on the same mechanisms since
> an atomic add doesn't need looping.

An atomic counter, featuring a wait when the value is in a certain
range, is known as semaphore.

--
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: Run this under Windows and Linux

<7td1N.116068$MJ59.17727@fx10.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
Newsgroups: comp.lang.c++
From: branimir...@icloud.com (Branimir Maksimovic)
Subject: Re: Run this under Windows and Linux
References: <uhnl0h$bm9a$1@dont-email.me>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 108
Message-ID: <7td1N.116068$MJ59.17727@fx10.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 03 Nov 2023 21:18:59 UTC
Organization: usenet-news.net
Date: Fri, 03 Nov 2023 21:18:59 GMT
X-Received-Bytes: 4196
 by: Branimir Maksimovic - Fri, 3 Nov 2023 21:18 UTC

On 2023-10-30, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> MSVC's C++20 semaphore class spins to acquire the semaphore;
> g++'s / libstdc++'s doesn't spin. I wote a little test program
> to rest how long it takes to flip to another thread and back
> with a binary_semaphore (always a counting_semaphore<1>).
> Here it is:
>
> #if defined(_WIN32)
> #include <Windows.h>
> #elif defined(__unix__)
> #include <sys/resource.h>
> #endif
> #include <iostream>
> #include <thread>
> #include <semaphore>
> #include <atomic>
> #include <utility>
> #include <vector>
>
> using namespace std;
>
> int main()
> {
> binary_semaphore
> semA( 1 ),
> semB( 0 );
> auto getTimes = []() -> pair<int64_t, int64_t>
> {
> #if defined(_WIN32)
> FILETIME ftDummy, ftKernel, ftUser;
> GetThreadTimes( GetCurrentThread(), &ftDummy, &ftDummy, &ftKernel,
> &ftUser );
> auto compose = []( FILETIME &ft ) { return
> ((uint64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime) * 100; };
> return { compose( ftKernel ), compose( ftUser ) };
> #elif defined(__unix__)
> rusage ru;
> getrusage( RUSAGE_THREAD, &ru );
> auto compose = []( timeval &tv ) -> int64_t { return
> (uint64_t)tv.tv_sec * 1'000'000'000u + (uint32_t)tv.tv_usec * 1'000u; };
> return { compose( ru.ru_stime ), compose( ru.ru_utime ) };
> #endif
> };
> atomic_int64_t
> aFlips( 0 ),
> aKernel( 0 ),
> aUser( 0 );
> atomic_bool stop( false );
> auto thr = [&]( binary_semaphore &semMe, binary_semaphore &semYou )
> {
> auto tBegin = getTimes();
> uint64_t f = 0;
> for( ; !stop.load( memory_order_relaxed ); ++f )
> semMe.acquire(),
> semYou.release();
> auto tEnd = getTimes();
> aFlips += f;
> aKernel += tEnd.first - tBegin.first;
> aUser += tEnd.second + tBegin.second;
> };
> vector<jthread> threads;
> threads.emplace_back( thr, ref( semA ), ref( semB ) );
> threads.emplace_back( thr, ref( semB ), ref( semA ) );
> this_thread::sleep_for( 1s );
> stop = true;
> threads.resize( 0 );
> double
> kernel = (double)aKernel,
> user = (double)aUser,
> total = kernel + user,
> flips = (double)aFlips;
> cout << user / total * 100.0 << "%" << endl;
> cout << total / flips << "ns" << endl;
> }
>
> Results unter Windows 11 on a AMD Ryzen 7950X (Zen4):
> 100%
> 89.3523ns
> So 100% of the CPU time is spent in user space and a flip back
> and forth takes 90ns.
> Results unter Ubuntu 20.04 on a AMD Threadripper 3990X (Zen2):
> 6.56209%
> 476.213ns
> So under Linux most of the time is spent in kernel space and I think
> about 0.5us, thats about 2000 clock cycles with full boost, isn't bad
> for an explicit kernel call.
> I think this userland spinning isn't really necessary because you
> normally a usual mutex and a condition_variable fits for everything
> you need. An explicit semaphore is rather needed if you build your
> own synchronization primitves on top of the semaphore. And if you do
> that you usually have your own spinning with that and you don't need
> further spinning if you want go into kernel mode. But this additional
> spinning actually doesn't really hurt since the kernel call itself
> costs a lot more.
>
maxa@Branimirs-MacBook-Air News % g++ -O2 run.cpp -o run -std=c++20
run.cpp:37:2: warning: non-void lambda does not return a value [-Wreturn-type]
};
^
1 warning generated.
bmaxa@Branimirs-MacBook-Air News % ./run
libc++abi: terminating
zsh: abort ./run

--

7-77-777, Evil Sinner!
https://www.linkedin.com/in/branimir-maksimovic-6762bbaa/

Re: Run this under Windows and Linux

<ui3rar$2vc30$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:13:47 -0700
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <ui3rar$2vc30$2@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhu543$1ns97$1@dont-email.me>
<uhu5c9$1nv1h$1@dont-email.me> <qjx0N.50766$f719.9718@fx42.iad>
<uhu7t2$1oeda$1@dont-email.me> <uhuat3$1omhf$7@dont-email.me>
<ui2pgj$2pd4h$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Nov 2023 22:13:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EEINqi9x8aaXeXxjsBvwflzwH+W7lPtA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:h6vCbvKmQ69U8uHfP1G4x2EsTL8=
In-Reply-To: <ui2pgj$2pd4h$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:13 UTC

On 11/3/2023 5:36 AM, Bonita Montero wrote:
> Am 01.11.2023 um 21:02 schrieb Chris M. Thomasson:
>
>> If you can avoid using a CAS, aka CMPXCHG over on intel, then do it!
>> Although, wrt intel, there is a way to use CMPXCHG without looping.
>
> I don't believe that, give me some code-example _here_. The expected
> value of a compare exchange might always have been asynchronously
> changed, so you need looping every time.
>
>> Think, strong CAS vs weak CAS...
>
> Strong CAS vs. weak CAS only makes a difference of architectures with
> LL/SC. With these architectures a CAS may fail although the actual
> data corresponds with the expected value because the cacheline might
> have been evicted in the meantime. compare_exchange_strong checks for
> this case and loops internally, whereas compare_exchange_weak gives a
> false result after one try.

Strong CAS cannot fail spuriously. Put on your thinking cap.

Re: Run this under Windows and Linux

<ui3rd0$2vc30$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:14:56 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ui3rd0$2vc30$3@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhu543$1ns97$1@dont-email.me>
<20231103160428.00007936@yahoo.com> <ui2vqr$2qcrs$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Nov 2023 22:14:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XxxkjWHcpEWHzrHMDTcR1ddDNv2RFvWs="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:5rYbl0oKtnyO7PZjnA0mvRD9CxA=
In-Reply-To: <ui2vqr$2qcrs$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:14 UTC

On 11/3/2023 7:24 AM, Bonita Montero wrote:
> Am 03.11.2023 um 15:04 schrieb Michael S:
>
>> Semophores can be efficiently implemented on "old" x86 by means of
>> 'LOCK ADD mem, reg'. ...
>
> Semaphores need much more code and this code is usually in the kernel
> since with a semaphore a thread may go to sleep or be awakened.

Huh? A semaphore in userspace is doable. We use a kernel semaphore for
the slow paths.

Re: Run this under Windows and Linux

<ui3rfg$2vc30$4@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:16:17 -0700
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <ui3rfg$2vc30$4@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <ROO0N.36030$AvZ9.22601@fx35.iad>
<ui0fi4$293il$1@dont-email.me> <ui0vru$2cie9$1@dont-email.me>
<ui2djl$2ngpf$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Nov 2023 22:16:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+udhthsbojWnhGyVKumUzKLsuSFb6oyUw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:KVuXdh8Ybh+UUcZ4rJMMw+bWfzY=
Content-Language: en-US
In-Reply-To: <ui2djl$2ngpf$1@dont-email.me>
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:16 UTC

On 11/3/2023 2:13 AM, David Brown wrote:
> On 02/11/2023 21:12, Chris M. Thomasson wrote:
>> On 11/2/2023 8:34 AM, David Brown wrote:
>>> On 02/11/2023 15:58, Scott Lurndal wrote:
>>>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>>>> Am 01.11.2023 um 20:58 schrieb Chris M. Thomasson:
>>>>>
>>>>>> The benaphore is a semaphore not a mutex! Fwiw, you can use any
>>>>>> semaphore as a binary semaphore for use as a mutex. Got it?
>>>>>
>>>>> A binary semaphore is also a mutex.
>>>>
>>>> No.  Each is distinct.
>>>>
>>>> It is correct, however, to say that both provide the same
>>>> functionality.
>>>>
>>>
>>> Both provide /similar/ functionality, but not necessarily the same.
>>> Different OS's differ in the details, but it is common for mutexes to
>>> have priority boosting if a high priority thread is waiting for a
>>> mutex currently held by a low priority thread.  Such boosting is
>>> normally not part of the functionality of a binary semaphore.  This
>>> makes them very distinctly different on such OS's - a mutex is a
>>> lock, a semaphore (binary or otherwise) is a signalling mechanism.
>>
>> Right. Basically, any thread/process can increment and/or decrement a
>> semaphore. This is different than pure mutex logic. Even if the mutex
>> uses a semaphore under the covers...
>>
>
> That's a very different issue - though of course it is an equally
> important distinction between mutexes and binary semaphores.  (And no, a
> mutex cannot be implemented using semaphores if the mutex has protection
> against priority inversion, and the semaphore does not.)

Agreed. Basically, the benaphore is a bakery algorithm. It has FIFO on
the mind... So, you are right.

>
>>>
>>> (I don't know if Windows makes such a distinction - it's not an OS
>>> you use when thread or process priority is important.  It is
>>> certainly common, though not universal, for RTOS's.  And while I
>>> don't know the details, I'd be surprised if Linux and other *nix's
>>> didn't have such a distinction.)
>>>
>>
>

Re: Run this under Windows and Linux

<ui3rjd$2vc30$5@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:18:22 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <ui3rjd$2vc30$5@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Nov 2023 22:18:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+g5iM6JlMCb2aOr/TLPWKtUOScJpCnNdk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8WSN+54SPYzs/9NAezQs3rpzP5U=
Content-Language: en-US
In-Reply-To: <ui2jik$2of1r$1@dont-email.me>
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:18 UTC

On 11/3/2023 3:55 AM, Bonita Montero wrote:
> Am 03.11.2023 um 10:15 schrieb David Brown:
>> On 02/11/2023 17:26, Bonita Montero wrote:
>>> Am 02.11.2023 um 17:00 schrieb Kaz Kylheku:
>>>
>>>> Locked isn't necessarily owned.
>>>> The semaphore does not record the ID of an owner.
>>>
>>> A non-recursive mutes also doesn't do this. The surrounding
>>> code itself is designed in a way that it behaves like an owner.
>>
>> Mutexes - recursive or non-recursive - /do/ record their owner when
>> the lock is taken. ...
>
> Absolutely not. You can take ownership of a mutex in one thread and
> release it in another thread.

Oh, really!?!?!? Yikes!

> The mentioned benaphore, which is the
> basic skeleton for all mutexes, is a good example for that.

Oh my. A benaphore is basically a userspace semaphore using a kernel
semaphore for slow paths.

Re: Run this under Windows and Linux

<ui3rko$2vc30$6@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:19:04 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <ui3rko$2vc30$6@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Nov 2023 22:19:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18quTMOdOpz2Md0MASkM4VYw55leqetvZA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BqOBLRebuVkWzh1OsI2SbDaehwU=
Content-Language: en-US
In-Reply-To: <ui34r0$2r7cc$1@dont-email.me>
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:19 UTC

On 11/3/2023 8:49 AM, Bonita Montero wrote:
> Am 03.11.2023 um 16:35 schrieb David Brown:
>
>> And using the definitions held by most people involved (including the
>> C++ standard library, the Windows API, and AFAIK POSIX), mutexes have
>> ownership and semaphores do not. ...
>
> Mutexes only have ownership if they're recursive.

WHAT!!! ? ;^o

Otherwise you
> can easily unlock a mutex which was locked in another thread.
>
>> A semaphore is not a lock, ...
>
> It can be used as a lock although it is not recommended because
> a semaphore is usually a pure kernel facility.
>
>

Re: Run this under Windows and Linux

<ui3rnv$2vc30$7@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.neodome.net!news.mixmin.net!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:20:48 -0700
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <ui3rnv$2vc30$7@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <ui393f$2s0sv$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Nov 2023 22:20:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18b8gMLCQZfD3YCgGslzeAu/qZUMT4HP/g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:jtlEen6BbMQBnnMkR1qYGNw0doA=
In-Reply-To: <ui393f$2s0sv$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:20 UTC

On 11/3/2023 10:02 AM, David Brown wrote:
> On 03/11/2023 16:49, Bonita Montero wrote:
>> Am 03.11.2023 um 16:35 schrieb David Brown:
>>
>>> And using the definitions held by most people involved (including the
>>> C++ standard library, the Windows API, and AFAIK POSIX), mutexes have
>>> ownership and semaphores do not. ...
>>
>> Mutexes only have ownership if they're recursive. Otherwise you
>> can easily unlock a mutex which was locked in another thread.
>>
>
> Please read <https://en.cppreference.com/w/cpp/thread/mutex/unlock>.
> Note the sentence "The mutex must be locked by the current thread of
> execution, otherwise, the behavior is undefined."
>
> Please read the C++ standards, section [thread.mutex.requirements.mutex]
> and note that for "unlock()", there is the sentence "Preconditions: The
> calling thread owns the mutex."
>
> Please learn what "undefined behaviour" means, and what "preconditions"
> mean.
>
> Then come back and apologise.

If I wait for that day, well, I will most likely be dead.

>
>>> A semaphore is not a lock, ...
>>
>> It can be used as a lock although it is not recommended because
>> a semaphore is usually a pure kernel facility.
>>
>
> Using a semaphore as a lock is not recommended because a semaphore does
> not make a good lock.  A main reason for that is that it has no concept
> of ownership.  /All/ locking and inter-thread signalling mechanisms rely
> on kernel facilities, because they need to be able to sleep, and to wake
> sleeping threads.
>
>

Re: Run this under Windows and Linux

<ui3rou$2vc30$8@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:21:19 -0700
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <ui3rou$2vc30$8@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <ui393f$2s0sv$1@dont-email.me>
<ui39dr$2s28j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Nov 2023 22:21:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eobLosBE/MiDvFZvj4zNIc7WX9fF0S24="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:D1Noex45uDhZxEKQOqwz537GqGI=
In-Reply-To: <ui39dr$2s28j$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:21 UTC

On 11/3/2023 10:08 AM, Bonita Montero wrote:
> Am 03.11.2023 um 18:02 schrieb David Brown:
>
>> Please read <https://en.cppreference.com/w/cpp/thread/mutex/unlock>.
>> Note the sentence "The mutex must be locked by the current thread of
>> execution, otherwise, the behavior is undefined."
>
> Maybe, but I'm talking about how mutexes usually work internally.
>
>
>> Using a semaphore as a lock is not recommended because a semaphore
>> does not make a good lock.  A main reason for that is that it has no
>> concept of ownership. ...
>
> Mutexes also usually have no notion of ownership.
>

The Art of Trolling, 123, all is me...

Re: Run this under Windows and Linux

<ui3ru6$2vc30$9@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:24:07 -0700
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <ui3ru6$2vc30$9@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <kA91N.279085$8fO.263728@fx15.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Nov 2023 22:24:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nUK5P+FmUhXSX22WhKSQiK3bQaANo2n0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:m4ia5yzGWJsw3qqoZ+TYuCOYDcY=
Content-Language: en-US
In-Reply-To: <kA91N.279085$8fO.263728@fx15.iad>
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:24 UTC

On 11/3/2023 9:53 AM, Scott Lurndal wrote:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>> Am 03.11.2023 um 10:15 schrieb David Brown:
>>> On 02/11/2023 17:26, Bonita Montero wrote:
>>>> Am 02.11.2023 um 17:00 schrieb Kaz Kylheku:
>>>>
>>>>> Locked isn't necessarily owned.
>>>>> The semaphore does not record the ID of an owner.
>>>>
>>>> A non-recursive mutes also doesn't do this. The surrounding
>>>> code itself is designed in a way that it behaves like an owner.
>>>
>>> Mutexes - recursive or non-recursive - /do/ record their owner when the
>>> lock is taken. ...
>>
>> Absolutely not. You can take ownership of a mutex in one thread and
>> release it in another thread.
>
> That has to be the worst idea you've proposed so far.

That should be framed! ;^O

Re: Run this under Windows and Linux

<ui3s05$2vc30$10@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:25:10 -0700
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <ui3s05$2vc30$10@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <kA91N.279085$8fO.263728@fx15.iad>
<ui39gf$2s28j$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Nov 2023 22:25:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0N2BId1ufqwiCTMHX28YXofDhjmpWLdo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:+nZsC6YOUn7vHSHwXnay6AkO+So=
In-Reply-To: <ui39gf$2s28j$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:25 UTC

On 11/3/2023 10:09 AM, Bonita Montero wrote:
> Am 03.11.2023 um 17:53 schrieb Scott Lurndal:
>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>> Am 03.11.2023 um 10:15 schrieb David Brown:
>>>> On 02/11/2023 17:26, Bonita Montero wrote:
>>>>> Am 02.11.2023 um 17:00 schrieb Kaz Kylheku:
>>>>>
>>>>>> Locked isn't necessarily owned.
>>>>>> The semaphore does not record the ID of an owner.
>>>>>
>>>>> A non-recursive mutes also doesn't do this. The surrounding
>>>>> code itself is designed in a way that it behaves like an owner.
>>>>
>>>> Mutexes - recursive or non-recursive - /do/ record their owner when the
>>>> lock is taken. ...
>>>
>>> Absolutely not. You can take ownership of a mutex in one thread and
>>> release it in another thread.
>>
>> That has to be the worst idea you've proposed so far.
>
> I won't say that this is recommendable but just that it is possible
> from the way how a mutex usually works. I just wanted to say with
> that that mutexes usually have no ownership. You can see that with
> the benapohre.
>

Oh shit. You have dug yourself into a really deep hole here, Bonita.

wow.

Re: Run this under Windows and Linux

<ui3s3c$2vc30$11@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Fri, 3 Nov 2023 15:26:53 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ui3s3c$2vc30$11@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com>
<ui3aob$2sa5j$1@dont-email.me> <20231103105439.435@kylheku.com>
<ui3csi$2sm3u$1@dont-email.me> <ui3cvg$2sngu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Nov 2023 22:26:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91d289698cb293a9fe1990fd164a4cc8";
logging-data="3125344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zMgtu66od3t/V6MtLAm5i+4YCUmJq/SM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:SGNbPpSOv21M0cFhRWewMKs/OQw=
Content-Language: en-US
In-Reply-To: <ui3cvg$2sngu$1@dont-email.me>
 by: Chris M. Thomasson - Fri, 3 Nov 2023 22:26 UTC

On 11/3/2023 11:08 AM, Bonita Montero wrote:
> Am 03.11.2023 um 19:07 schrieb Bonita Montero:
>
>> It's a mutex, look at the code.
>> And look at the discussion on stack overflow about that:
>> https://stackoverflow.com/questions/1635416/are-benaphores-worth-implementing-on-modern-oss
>
> And this article also refers to it as a mutex:
> https://preshing.com/20120226/roll-your-own-lightweight-mutex/
>

Oh my god...

Re: Run this under Windows and Linux

<ui4q7n$38rsj$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Sat, 4 Nov 2023 00:01:12 -0700
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ui4q7n$38rsj$2@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtfrr$1jvsr$1@dont-email.me> <uhuaml$1omhf$5@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 07:01:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3436435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+k9Dyytynm6eVd30xAEaJg+vRc89Y/2WA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:33uBtceC6J0dwD3/WNGUum9Kq9c=
Content-Language: en-US
In-Reply-To: <uhuaml$1omhf$5@dont-email.me>
 by: Chris M. Thomasson - Sat, 4 Nov 2023 07:01 UTC

On 11/1/2023 12:59 PM, Chris M. Thomasson wrote:
> On 11/1/2023 5:21 AM, Bonita Montero wrote:
>> Am 31.10.2023 um 21:59 schrieb Chris M. Thomasson:
>>
>>> Why do you say that?
>>
>> The article you mentioned is also discussed here:
>> https://stackoverflow.com/questions/1635416/are-benaphores-worth-implementing-on-modern-oss
>> The first replier says the same I said: its a normal mutex.
>>
>
> Huh? The benaphore is a semaphore! So, both of you are totally wrong
> here. Think about it...

Your theme song?

https://youtu.be/FE-hBbBBGBs

Re: Run this under Windows and Linux

<ui4r9g$38rsj$6@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Sat, 4 Nov 2023 00:19:12 -0700
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <ui4r9g$38rsj$6@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhu543$1ns97$1@dont-email.me>
<uhu5c9$1nv1h$1@dont-email.me> <qjx0N.50766$f719.9718@fx42.iad>
<uhu7t2$1oeda$1@dont-email.me> <uhuat3$1omhf$7@dont-email.me>
<ui2pgj$2pd4h$1@dont-email.me> <ui3rar$2vc30$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 07:19:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3436435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183UM2tbY7c9y3fNEkFkepnyMFolA9otOo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:4OHIUyjyeFwamoROlxKtT10mJYk=
Content-Language: en-US
In-Reply-To: <ui3rar$2vc30$2@dont-email.me>
 by: Chris M. Thomasson - Sat, 4 Nov 2023 07:19 UTC

On 11/3/2023 3:13 PM, Chris M. Thomasson wrote:
> On 11/3/2023 5:36 AM, Bonita Montero wrote:
>> Am 01.11.2023 um 21:02 schrieb Chris M. Thomasson:
>>
>>> If you can avoid using a CAS, aka CMPXCHG over on intel, then do it!
>>> Although, wrt intel, there is a way to use CMPXCHG without looping.
>>
>> I don't believe that, give me some code-example _here_. The expected
>> value of a compare exchange might always have been asynchronously
>> changed, so you need looping every time.
>>
>>> Think, strong CAS vs weak CAS...
>>
>> Strong CAS vs. weak CAS only makes a difference of architectures with
>> LL/SC. With these architectures a CAS may fail although the actual
>> data corresponds with the expected value because the cacheline might
>> have been evicted in the meantime. compare_exchange_strong checks for
>> this case and loops internally, whereas compare_exchange_weak gives a
>> false result after one try.
>
> Strong CAS cannot fail spuriously. Put on your thinking cap.
>

CMPXCHG cannot fail spuriously. However, LL/SC can.

Re: Run this under Windows and Linux

<ui520c$3a606$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Sat, 4 Nov 2023 10:13:53 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ui520c$3a606$1@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhu543$1ns97$1@dont-email.me>
<uhu5c9$1nv1h$1@dont-email.me> <qjx0N.50766$f719.9718@fx42.iad>
<uhu7t2$1oeda$1@dont-email.me> <uhuat3$1omhf$7@dont-email.me>
<ui2pgj$2pd4h$1@dont-email.me> <ui3rar$2vc30$2@dont-email.me>
<ui4r9g$38rsj$6@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 09:13:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3479558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YwhwiAxW5V3sGoxegOe8RoXMVd6quWOo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BQWvhCnCaQ162YYPlJRN/nLHCKY=
Content-Language: de-DE
In-Reply-To: <ui4r9g$38rsj$6@dont-email.me>
 by: Bonita Montero - Sat, 4 Nov 2023 09:13 UTC

Am 04.11.2023 um 08:19 schrieb Chris M. Thomasson:
> On 11/3/2023 3:13 PM, Chris M. Thomasson wrote:

>> On 11/3/2023 5:36 AM, Bonita Montero wrote:

>>> Strong CAS vs. weak CAS only makes a difference of architectures with
>>> LL/SC. With these architectures a CAS may fail although the actual
>>> data corresponds with the expected value because the cacheline might
>>> have been evicted in the meantime. compare_exchange_strong checks for
>>> this case and loops internally, whereas compare_exchange_weak gives a
>>> false result after one try.

>> Strong CAS cannot fail spuriously. Put on your thinking cap.

> CMPXCHG cannot fail spuriously. However, LL/SC can.

Youre telling things I've told above in a different way.

Re: Run this under Windows and Linux

<ui522k$3a606$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Sat, 4 Nov 2023 10:15:05 +0100
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ui522k$3a606$2@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <20231103102128.731@kylheku.com>
<ui3aob$2sa5j$1@dont-email.me> <zlb1N.177702$sxoa.164234@fx13.iad>
<ui3hec$2th64$1@dont-email.me> <20231103135319.1@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 09:15:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3479558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+J9C/EreLyCHhAcTXWAOfC+ThgjGK4IqU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:pQBWLtY5/0qtb7B4qleXUJrzqlE=
Content-Language: de-DE
In-Reply-To: <20231103135319.1@kylheku.com>
 by: Bonita Montero - Sat, 4 Nov 2023 09:15 UTC

Am 03.11.2023 um 21:56 schrieb Kaz Kylheku:

> An atomic counter, featuring a wait when the value is in a certain
> range, is known as semaphore.

An atomic counter alone isn't sufficient for a semaphore because
there's no way to sleep or to be awakened with that.

Re: Run this under Windows and Linux

<ui524s$3a606$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Sat, 4 Nov 2023 10:16:16 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <ui524s$3a606$3@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <uhp2gk$jvlg$1@dont-email.me>
<uhqrnb$11io0$1@dont-email.me> <uhrprb$175ve$1@dont-email.me>
<uhtekk$1jn05$1@dont-email.me> <uhual7$1omhf$4@dont-email.me>
<uhveha$22bbn$2@dont-email.me> <20231102083305.904@kylheku.com>
<ui0gbs$29990$3@dont-email.me> <20231102085649.385@kylheku.com>
<ui0ijl$29qan$1@dont-email.me> <ui2do8$2ngpf$2@dont-email.me>
<ui2jik$2of1r$1@dont-email.me> <ui2tah$2q17j$1@dont-email.me>
<ui2vnl$2qcrs$1@dont-email.me> <ui340b$2r25r$1@dont-email.me>
<ui34r0$2r7cc$1@dont-email.me> <ui3rko$2vc30$6@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 09:16:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3479558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zIhBcqvW/xMrjlIV9ztuXJSSnXQKsYZM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:QggLqKVgGvJ3u9HGUkr33aifhWM=
In-Reply-To: <ui3rko$2vc30$6@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 4 Nov 2023 09:16 UTC

Am 03.11.2023 um 23:19 schrieb Chris M. Thomasson:
> On 11/3/2023 8:49 AM, Bonita Montero wrote:
>> Am 03.11.2023 um 16:35 schrieb David Brown:
>>
>>> And using the definitions held by most people involved (including the
>>> C++ standard library, the Windows API, and AFAIK POSIX), mutexes have
>>> ownership and semaphores do not. ...
>>
>> Mutexes only have ownership if they're recursive.
>
> WHAT!!! ? ;^o

It't the surrounding code that "knows" that it is
an owner, not the mutex itself. A non-recurive mutex
just knows that it is owned, but not by whom.


devel / comp.lang.c++ / Re: Run this under Windows and Linux

Pages:1234567
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor