Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

C++ is the best example of second-system effect since OS/360.


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

<ui526u$3a606$4@dont-email.me>

  copy mid

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

  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:17:22 +0100
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <ui526u$3a606$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> <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> <ui3s05$2vc30$10@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:17:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3479558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5331DbbzWZhTl7SNtc5keIiYbq2Y7M5o="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:f51a9mjKIpwZNaWeT8oiO/W7EzY=
Content-Language: de-DE
In-Reply-To: <ui3s05$2vc30$10@dont-email.me>
 by: Bonita Montero - Sat, 4 Nov 2023 09:17 UTC

Am 03.11.2023 um 23:25 schrieb Chris M. Thomasson:

> On 11/3/2023 10:09 AM, Bonita Montero wrote:

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

The benaphore does know that it is owned, but not by whom.
Its the surrounding code that knows that it owns the mutex.

Re: Run this under Windows and Linux

<ui528p$3a606$5@dont-email.me>

  copy mid

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

  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:18:21 +0100
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ui528p$3a606$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> <ui3rjd$2vc30$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 09:18:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3479558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//ElExZEzDAZl8J6BvhuaqPUu9aje63Qc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:h0feRxn50hS83EUYDfslfgoOjCk=
In-Reply-To: <ui3rjd$2vc30$5@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 4 Nov 2023 09:18 UTC

Am 03.11.2023 um 23:18 schrieb Chris M. Thomasson:

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

There isn't sth. like a userspace semaphore since with a sempahore
you need support to sleep or to be awakened.

Re: Run this under Windows and Linux

<ui52bd$3a606$6@dont-email.me>

  copy mid

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

  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:19:46 +0100
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ui52bd$3a606$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>
<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 09:19:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3479558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pL9wfQESUqUzLQ7zE/NT2uq07qoM+RBw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:HKSNJd2l8ebkbC4SYUbyE9BiKos=
Content-Language: de-DE
In-Reply-To: <uhuaml$1omhf$5@dont-email.me>
 by: Bonita Montero - Sat, 4 Nov 2023 09:19 UTC

Am 01.11.2023 um 20:59 schrieb Chris M. Thomasson:

> Huh? The benaphore is a semaphore! So, both of you are totally wrong
> here. Think about it...

Google for "benaphore mutex" and you'll find several refernces that a
benaphore is a mutex, including the two articles I've referred so far.

Re: Run this under Windows and Linux

<ui52m2$3a606$7@dont-email.me>

  copy mid

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

  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:25:26 +0100
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <ui52m2$3a606$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> <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:25:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3479558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18OzS2Nh5kzkQ9gdLaG7KNIqjuCsd1tL6k="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:rTiOyLemnSeW7qW6gbUyhOeqPBo=
In-Reply-To: <ui3rko$2vc30$6@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 4 Nov 2023 09:25 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's not necessary to record ownership of a specific thread for a non
recursive mutex but just _that_ a mutex is ownend, and not by whom.
The benaphore can easily locked in one thread and unlocked in another
thread, although this usually doesn't happen.
It's just the surrounding code that successfully locked a mutex that
"knows" it is the owner.

> 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

<ui52ta$3aaiu$1@dont-email.me>

  copy mid

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

  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:29:18 +0100
Organization: A noiseless patient Spider
Lines: 110
Message-ID: <ui52ta$3aaiu$1@dont-email.me>
References: <uhnl0h$bm9a$1@dont-email.me> <7td1N.116068$MJ59.17727@fx10.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 09:29:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3484254"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rUHbYQtpEdMdJiMp3wlk+0Vh6PmOi7aA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ycSmSYm5Rv13Y+95RmaS+izcpj4=
Content-Language: de-DE
In-Reply-To: <7td1N.116068$MJ59.17727@fx10.iad>
 by: Bonita Montero - Sat, 4 Nov 2023 09:29 UTC

Maybe I missed some header which is implicitly included with me.
The code compiles fine with g++, clang++, clang-cl and MSVC on
my PC.

Am 03.11.2023 um 22:18 schrieb Branimir Maksimovic:
> 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
>

Re: Run this under Windows and Linux

<ui54be$3ai3f$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.nntp4.net!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:53:54 +0100
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <ui54be$3ai3f$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>
<uhtfrr$1jvsr$1@dont-email.me> <uhuaml$1omhf$5@dont-email.me>
<ui52bd$3a606$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:53:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3491951"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mz8A2iId1lJmS+f/34WffZHUF1uEhQCM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cM/CxGuv0ymHah/Hrxzl1cwQwP8=
In-Reply-To: <ui52bd$3a606$6@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 4 Nov 2023 09:53 UTC

Am 04.11.2023 um 10:19 schrieb Bonita Montero:

> Google for "benaphore mutex" ...
Or rather "benaphore mutex -semaphore".

Re: Run this under Windows and Linux

<3Ot1N.211576$0UVe.86208@fx17.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
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> <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>
Lines: 29
Message-ID: <3Ot1N.211576$0UVe.86208@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sat, 04 Nov 2023 15:53:35 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sat, 04 Nov 2023 15:53:35 GMT
X-Received-Bytes: 2128
 by: Scott Lurndal - Sat, 4 Nov 2023 15:53 UTC

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>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.

LL/SC is not compare and swap.

Re: Run this under Windows and Linux

<ui5pmq$3e8l1$1@dont-email.me>

  copy mid

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

  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 16:58:22 +0100
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <ui5pmq$3e8l1$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> <3Ot1N.211576$0UVe.86208@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 15:58:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3613345"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sJ/yS0I03P6mU3OHdfgTw8nWewDAjXRY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NR800YBOHjqsNCJJPDb4roAo3qk=
Content-Language: de-DE
In-Reply-To: <3Ot1N.211576$0UVe.86208@fx17.iad>
 by: Bonita Montero - Sat, 4 Nov 2023 15:58 UTC

Am 04.11.2023 um 16:53 schrieb Scott Lurndal:
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>> 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.
>
> LL/SC is not compare and swap.

Cite where I said sth. opposite.

Re: Run this under Windows and Linux

<jXt1N.211577$0UVe.61104@fx17.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
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> <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>
Lines: 51
Message-ID: <jXt1N.211577$0UVe.61104@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sat, 04 Nov 2023 16:03:27 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sat, 04 Nov 2023 16:03:27 GMT
X-Received-Bytes: 3419
 by: Scott Lurndal - Sat, 4 Nov 2023 16:03 UTC

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>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.
>

BTW - Compare and Swap was invented by an engineer at IBM -
CAS is a backronym, the inventors initials are CAS.

https://www.garlic.com/~lynn/2004l.html#56

"charlie had come up with compare and swap at the science scenter
http://www.garlic.com/~lynn/subtopic.html#545tech
based on a lot of work he was doing in fine grain locking (late 60s)
... and tried to get it into 370 architecture. POK architecture owners
came back and said it wasn't possible to justify a multiprocessor-specific
instruction for the 370 architecture (already having test&set) ... and that
to get it justified, it would be necessary to come up with a non-multiprocessor
use for the instruction. thus was born the description for multi-threaded
application use in non-locked regions .... when running on either
multiprocessor or non-multiprocessor machines. this was originally
included in the 370 prinicple of operations as programming notes
associated with the compare&swap instruction(s). the description has
since been expanded and moved to the principles of operation appendix.

note that the choice of compare and swap comes from needing a mnemonic
that matched charlie's initials (CAS). the mnemonic was slightly changed
for inclusion in 370 to CS (compare and swap) and CDS (compare double and swap).

the instructions have since been expanded for 64-bit operation and a
new "perform locked operation" has since been added.

Re: Run this under Windows and Linux

<fZt1N.211578$0UVe.68947@fx17.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
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> <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> <ui522k$3a606$2@dont-email.me>
Lines: 11
Message-ID: <fZt1N.211578$0UVe.68947@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sat, 04 Nov 2023 16:05:31 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sat, 04 Nov 2023 16:05:31 GMT
X-Received-Bytes: 1378
 by: Scott Lurndal - Sat, 4 Nov 2023 16:05 UTC

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

Sure there is. It's even obvious.

Re: Run this under Windows and Linux

<ui5r4b$3eh87$1@dont-email.me>

  copy mid

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

  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: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Sat, 4 Nov 2023 17:22:35 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <ui5r4b$3eh87$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> <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: Sat, 4 Nov 2023 16:22:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4526d8cd1da42137165b68d085744caf";
logging-data="3622151"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Y1K/6iJM80a6Y8w8006IwWvYpiIAvd4U="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:pki1Yu/hJZh0PQimpOiCNtxMecI=
In-Reply-To: <ui39dr$2s28j$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Sat, 4 Nov 2023 16:22 UTC

On 03/11/2023 18:08, 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.
>

I think, from this thread, it is clear that you have no idea how mutexes
are used. I therefore assume you have no idea how they work internally.
And I am entirely confident that your idea of "usually" is limited to
one single OS.

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

I stand corrected. Your idea of "usually" is limited to no OS in existence.

Re: Run this under Windows and Linux

<ui5rrt$3el49$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.swapon.de!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 17:35:13 +0100
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ui5rrt$3el49$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> <ui393f$2s0sv$1@dont-email.me>
<ui39dr$2s28j$1@dont-email.me> <ui5r4b$3eh87$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Nov 2023 16:35:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3626121"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18s/l+/8EEdJvMwfAZvoGZFd9MgcWOVfdg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:T8ys3Z8AbKeWx9IEEw9Nh5VLUQU=
Content-Language: de-DE
In-Reply-To: <ui5r4b$3eh87$1@dont-email.me>
 by: Bonita Montero - Sat, 4 Nov 2023 16:35 UTC

Am 04.11.2023 um 17:22 schrieb David Brown:

> I think, from this thread, it is clear that you have no idea how mutexes
> are used. ...

I use them every day and I've developed my own reader's-writer-lock.

> I stand corrected.  Your idea of "usually" is limited to no OS in
> existence.

A non-recurive mutex doensn't need to know which thread is the
owner, but just that there's an owner.

Re: Run this under Windows and Linux

<ui5rsv$3el49$2@dont-email.me>

  copy mid

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

  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 17:35:47 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ui5rsv$3el49$2@dont-email.me>
References: <uhnl0h$bm9a$1@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>
<ui522k$3a606$2@dont-email.me> <fZt1N.211578$0UVe.68947@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 16:35:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3626121"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Xiz6i0SjhoN0vdY75UVdd4G9npVDi4z8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NXZvb2eNv4/I2eNG4iq9NY9h3/4=
Content-Language: de-DE
In-Reply-To: <fZt1N.211578$0UVe.68947@fx17.iad>
 by: Bonita Montero - Sat, 4 Nov 2023 16:35 UTC

Am 04.11.2023 um 17:05 schrieb Scott Lurndal:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>> 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.
>
> Sure there is. It's even obvious.

Not for Kaz.

Re: Run this under Windows and Linux

<ui5t30$3eqgc$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!nntp.comgw.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Sat, 4 Nov 2023 17:56:00 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <ui5t30$3eqgc$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> <ui393f$2s0sv$1@dont-email.me>
<ui39dr$2s28j$1@dont-email.me> <ui5r4b$3eh87$1@dont-email.me>
<ui5rrt$3el49$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Nov 2023 16:56:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4526d8cd1da42137165b68d085744caf";
logging-data="3631628"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dUvOqTPSFViNHWqWdWTU90OrHBOwNbF0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6PNldvZd8VRy9YD9FZdmLwbcvtg=
Content-Language: en-GB
In-Reply-To: <ui5rrt$3el49$1@dont-email.me>
 by: David Brown - Sat, 4 Nov 2023 16:56 UTC

On 04/11/2023 17:35, Bonita Montero wrote:
> Am 04.11.2023 um 17:22 schrieb David Brown:
>
>> I think, from this thread, it is clear that you have no idea how
>> mutexes are used. ...
>
> I use them every day and I've developed my own reader's-writer-lock.
>

Do you do all your work relying on luck?

>> I stand corrected.  Your idea of "usually" is limited to no OS in
>> existence.
>
> A non-recurive mutex doensn't need to know which thread is the
> owner, but just that there's an owner.
>

No, it needs to know the owner - because only the owner is allowed to
release the lock.

I suppose you could make a half-arsed mutex implementation that relies
on programmers never making mistakes, and just let the nasal demons fly
when people like you can't read and follow specifications.

And even if you have such a poor mutex implementation, conceptually
there is always an owner when the lock is taken - that's the point of
the thing.

Re: Run this under Windows and Linux

<ui5udh$3f4m5$1@dont-email.me>

  copy mid

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

  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 18:18:45 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ui5udh$3f4m5$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> <ui393f$2s0sv$1@dont-email.me>
<ui39dr$2s28j$1@dont-email.me> <ui5r4b$3eh87$1@dont-email.me>
<ui5rrt$3el49$1@dont-email.me> <ui5t30$3eqgc$1@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 17:18:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3642053"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+85fLqGZfgNzhvLOeIByxn5QbQ8nBGL9g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:eLpGIJTpBdbQ+qyRyEAHg9pYVrY=
In-Reply-To: <ui5t30$3eqgc$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 4 Nov 2023 17:18 UTC

Am 04.11.2023 um 17:56 schrieb David Brown:

> No, it needs to know the owner - because only the owner is allowed to
> release the lock.

This is a superfluous check that does not determine function.

> I suppose you could make a half-arsed mutex implementation that relies
> on programmers never making mistakes, and just let the nasal demons fly
> when people like you can't read and follow specifications.

It may be possible to release a mutex from another thread, but as no
one does this this check doesn't make sense. That that much unlikely
that that happens that it doesn't make sense as a debugging aid, even
more in C++, where you can't forget unlocking inside the same thread
if you use a unique_lock<> or lock_guard<>.

Re: Run this under Windows and Linux

<ui63dh$3g2ju$1@dont-email.me>

  copy mid

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

  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 11:44:02 -0700
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <ui63dh$3g2ju$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> <3Ot1N.211576$0UVe.86208@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 18:44:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3672702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cviQK/d+0Gq1EsPAYYycoWBoA63JYldM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Amps2V6y/RqwvffNJrs7cueAY+c=
In-Reply-To: <3Ot1N.211576$0UVe.86208@fx17.iad>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 4 Nov 2023 18:44 UTC

On 11/4/2023 8:53 AM, Scott Lurndal wrote:
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>> 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.
>
> LL/SC is not compare and swap.
>
>

LL/SC can be used to implement a weak CAS. Also, wrt the algorithm, it
can be used to implement a strong CAS.

CMPXCHG over on intel cannot be used to implement a weak CAS.

Re: Run this under Windows and Linux

<20231104114042.123@kylheku.com>

  copy mid

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

  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: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Run this under Windows and Linux
Date: Sat, 4 Nov 2023 18:44:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <20231104114042.123@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> <20231103135319.1@kylheku.com>
<ui522k$3a606$2@dont-email.me>
Injection-Date: Sat, 4 Nov 2023 18:44:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="381e374add7305c507ce66a0ee328190";
logging-data="3672286"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191risHzvnb5p9JjDa4hbCS6si7q/l0eOw="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:MBY2GDQrW7llohliBQOfWScitl8=
 by: Kaz Kylheku - Sat, 4 Nov 2023 18:44 UTC

On 2023-11-04, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> 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.

You're not successfully making it appear as if I said that.

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

<ui63ga$3g2ju$2@dont-email.me>

  copy mid

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

  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 11:45:31 -0700
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <ui63ga$3g2ju$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> <ui3rar$2vc30$2@dont-email.me>
<jXt1N.211577$0UVe.61104@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 18:45:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3672702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vM42yETvYl/071590b0JZs/388towJa8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:wYDuDhhlQRtk0drsRH3PTp8N9z0=
In-Reply-To: <jXt1N.211577$0UVe.61104@fx17.iad>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 4 Nov 2023 18:45 UTC

On 11/4/2023 9:03 AM, Scott Lurndal wrote:
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>> 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.
>>
>
> BTW - Compare and Swap was invented by an engineer at IBM -
> CAS is a backronym, the inventors initials are CAS.
>
> https://www.garlic.com/~lynn/2004l.html#56
>
>
> "charlie had come up with compare and swap at the science scenter
> http://www.garlic.com/~lynn/subtopic.html#545tech
> based on a lot of work he was doing in fine grain locking (late 60s)
> ... and tried to get it into 370 architecture. POK architecture owners
> came back and said it wasn't possible to justify a multiprocessor-specific
> instruction for the 370 architecture (already having test&set) ... and that
> to get it justified, it would be necessary to come up with a non-multiprocessor
> use for the instruction. thus was born the description for multi-threaded
> application use in non-locked regions .... when running on either
> multiprocessor or non-multiprocessor machines. this was originally
> included in the 370 prinicple of operations as programming notes
> associated with the compare&swap instruction(s). the description has
> since been expanded and moved to the principles of operation appendix.
>
> note that the choice of compare and swap comes from needing a mnemonic
> that matched charlie's initials (CAS). the mnemonic was slightly changed
> for inclusion in 370 to CS (compare and swap) and CDS (compare double and swap).
>
> the instructions have since been expanded for 64-bit operation and a
> new "perform locked operation" has since been added.
>
>

Yup. I have actually conversed with Lynn over on comp.arch. Very smart
person loaded up with knowledge.

Re: Run this under Windows and Linux

<ui63lf$3g2ju$3@dont-email.me>

  copy mid

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

  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 11:48:16 -0700
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <ui63lf$3g2ju$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>
<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>
<jXt1N.211577$0UVe.61104@fx17.iad> <ui63ga$3g2ju$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Nov 2023 18:48:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3672702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RJk+pnPy2H/GiF4ZzE+6VEsyUc3rihYU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:jM9Vy6G/qHljDF7QGyPw4mUCBkI=
In-Reply-To: <ui63ga$3g2ju$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 4 Nov 2023 18:48 UTC

On 11/4/2023 11:45 AM, Chris M. Thomasson wrote:
> On 11/4/2023 9:03 AM, Scott Lurndal wrote:
>> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>>> 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.
>>>
>>
>> BTW - Compare and Swap was invented by an engineer at IBM -
>> CAS is a backronym, the inventors initials are CAS.
>>
>> https://www.garlic.com/~lynn/2004l.html#56
>>
>>
>>    "charlie had come up with compare and swap at the science scenter
>>       http://www.garlic.com/~lynn/subtopic.html#545tech
>>     based on a lot of work he was doing in fine grain locking (late 60s)
>>     ... and tried to get it into 370 architecture. POK architecture
>> owners
>>     came back and said it wasn't possible to justify a
>> multiprocessor-specific
>>     instruction for the 370 architecture (already having test&set) ...
>> and that
>>     to get it justified, it would be necessary to come up with a
>> non-multiprocessor
>>     use for the instruction. thus was born the description for
>> multi-threaded
>>     application use in non-locked regions .... when running on either
>>     multiprocessor or non-multiprocessor machines. this was originally
>>     included in the 370 prinicple of operations as programming notes
>>     associated with the compare&swap instruction(s). the description has
>>     since been expanded and moved to the principles of operation
>> appendix.
>>
>>    note that the choice of compare and swap comes from needing a mnemonic
>>    that matched charlie's initials (CAS). the mnemonic was slightly
>> changed
>>    for inclusion in 370 to CS (compare and swap) and CDS (compare
>> double and swap).
>>
>>    the instructions have since been expanded for 64-bit operation and a
>>    new "perform locked operation" has since been added.
>>
>>
>
> Yup. I have actually conversed with Lynn over on comp.arch. Very smart
> person loaded up with knowledge.

The free pool manipulation in IBM's principle of operations, iirc, its
in an appendix.

Re: Run this under Windows and Linux

<ui647q$3gg0d$1@dont-email.me>

  copy mid

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

  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 19:58:06 +0100
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ui647q$3gg0d$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>
<jXt1N.211577$0UVe.61104@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Nov 2023 18:58:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a79ea9fefb8ec5d651072748f2b4162";
logging-data="3686413"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KNS2GRj3UACOvb+FZhUC9ct+zwNfHDCc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:xBw+j/1C+nga/xMqudnn3x+2zGA=
Content-Language: de-DE
In-Reply-To: <jXt1N.211577$0UVe.61104@fx17.iad>
 by: Bonita Montero - Sat, 4 Nov 2023 18:58 UTC

Am 04.11.2023 um 17:03 schrieb Scott Lurndal:
> BTW - Compare and Swap was invented by an engineer at IBM -
> ...

The idea is not that complex that it would have been invented by
a lot of technichians later. I think that LL/SC is more sexy since
it allows lock-free stacks with one word.

Re: Run this under Windows and Linux

<ui6579$3h0fh$1@dont-email.me>

  copy mid

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

  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 12:14:50 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ui6579$3h0fh$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>
<jXt1N.211577$0UVe.61104@fx17.iad> <ui647q$3gg0d$1@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 19:14:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3703281"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cl5SkX1uH9QqeasSo68ZxkKHeZCmRMtc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7s46PqUIRd0FkCRi3QNT7kLGG+k=
In-Reply-To: <ui647q$3gg0d$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 4 Nov 2023 19:14 UTC

On 11/4/2023 11:58 AM, Bonita Montero wrote:
> Am 04.11.2023 um 17:03 schrieb Scott Lurndal:
>> BTW - Compare and Swap was invented by an engineer at IBM -
>> ...
>
> The idea is not that complex that it would have been invented by
> a lot of technichians later. I think that LL/SC is more sexy since
> it allows lock-free stacks with one word.
>

Just be careful wrt the reservation granularity. LL/SC can be prone to
livelock.

Re: Run this under Windows and Linux

<ui66rq$3haup$1@dont-email.me>

  copy mid

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

  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 12:42:51 -0700
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <ui66rq$3haup$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> <ui3rko$2vc30$6@dont-email.me>
<ui52m2$3a606$7@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 19:42:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3714009"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZxzQ70f44skAhzXqsNT9EQ3/nG7vq9zc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:d1gvUffgFXy+jNzGkMmQtmhaC5Q=
In-Reply-To: <ui52m2$3a606$7@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 4 Nov 2023 19:42 UTC

On 11/4/2023 2:25 AM, Bonita Montero wrote:
> 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's not necessary to record ownership of a specific thread for a non
> recursive mutex but just _that_ a mutex is ownend, and not by whom.
> The benaphore can easily locked in one thread and unlocked in another
> thread, although this usually doesn't happen.
> It's just the surrounding code that successfully locked a mutex that
> "knows" it is the owner.

The surrounding code is the mutex. It can use a kernel semaphore for
slow paths. You seem to be radically confused.

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

<ui66u7$3haup$2@dont-email.me>

  copy mid

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

  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 12:44:07 -0700
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <ui66u7$3haup$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> <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> <ui3s05$2vc30$10@dont-email.me>
<ui526u$3a606$4@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 19:44:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3714009"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9v/7U2Lri4x7fm5EVIRXFdhh7RvW5CLM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:MsgKURd4lkKEHNQFC/D5Iv7wGIY=
In-Reply-To: <ui526u$3a606$4@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 4 Nov 2023 19:44 UTC

On 11/4/2023 2:17 AM, Bonita Montero wrote:
> Am 03.11.2023 um 23:25 schrieb Chris M. Thomasson:
>
>> On 11/3/2023 10:09 AM, Bonita Montero wrote:
>
>>> 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.
>
> The benaphore does know that it is owned, but not by whom.
> Its the surrounding code that knows that it owns the mutex.

Oh god. The benaphore is a semaphore. Mutex logic using a semaphore for
a slow path is different than a semaphore. God damn, man... You are
confused and/or trolling? Humm...

Re: Run this under Windows and Linux

<ui670n$3haup$3@dont-email.me>

  copy mid

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

  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 12:45:28 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ui670n$3haup$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> <ui3rjd$2vc30$5@dont-email.me>
<ui528p$3a606$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 19:45:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3714009"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19A/2DS/kQ1em5x0D5z4j8K4BEOMuHUmAg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:jfHSyz2sMsfwhYgHoX53y8pLNR4=
In-Reply-To: <ui528p$3a606$5@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 4 Nov 2023 19:45 UTC

On 11/4/2023 2:18 AM, Bonita Montero wrote:
> Am 03.11.2023 um 23:18 schrieb Chris M. Thomasson:
>
>> Oh my. A benaphore is basically a userspace semaphore using a kernel
>> semaphore for slow paths.
>
> There isn't sth. like a userspace semaphore since with a sempahore
> you need support to sleep or to be awakened.
>
>

Huh? The point of the benaphore (a semaphore) is to try to avoid going
into the kernel to sleep or to be awakened.

God damn it Bonita!

Re: Run this under Windows and Linux

<ui67bq$3haup$4@dont-email.me>

  copy mid

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

  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 12:51:23 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ui67bq$3haup$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>
<uhtfrr$1jvsr$1@dont-email.me> <uhuaml$1omhf$5@dont-email.me>
<ui52bd$3a606$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 19:51:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c00f701077870f387d02c0aec410f965";
logging-data="3714009"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pUTQ/uJc3XniHWqi5+xqvpnqHuZeUNLA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:m8TH/YDKkhEP6H/c03ApC5/yFB0=
Content-Language: en-US
In-Reply-To: <ui52bd$3a606$6@dont-email.me>
 by: Chris M. Thomasson - Sat, 4 Nov 2023 19:51 UTC

On 11/4/2023 2:19 AM, Bonita Montero wrote:
> Am 01.11.2023 um 20:59 schrieb Chris M. Thomasson:
>
>> Huh? The benaphore is a semaphore! So, both of you are totally wrong
>> here. Think about it...
>
> Google for "benaphore mutex" and you'll find several refernces that a
> benaphore is a mutex, including the two articles I've referred so far.
>

MORON!!!


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

Pages:1234567
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor