Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"They ought to make butt-flavored cat food." --Gallagher


devel / comp.lang.c++ / Re: A Java- / .NET-like monitor

SubjectAuthor
* A Java- / .NET-like monitorBonita Montero
+* Re: A Java- / .NET-like monitorBonita Montero
|`* Re: A Java- / .NET-like monitorChris M. Thomasson
| +* Re: A Java- / .NET-like monitorChris M. Thomasson
| |+* Re: A Java- / .NET-like monitorBonita Montero
| ||`- Re: A Java- / .NET-like monitorChris M. Thomasson
| |`- Re: A Java- / .NET-like monitorChris M. Thomasson
| `* Re: A Java- / .NET-like monitorBonita Montero
|  `- Re: A Java- / .NET-like monitorChris M. Thomasson
+* Re: A Java- / .NET-like monitorKaz Kylheku
|`* Re: A Java- / .NET-like monitorBonita Montero
| `* Re: A Java- / .NET-like monitorKaz Kylheku
|  `* Re: A Java- / .NET-like monitorBonita Montero
|   +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   |`* Re: A Java- / .NET-like monitorKaz Kylheku
|   | `- Re: A Java- / .NET-like monitorChris M. Thomasson
|   +* Re: A Java- / .NET-like monitorKaz Kylheku
|   |`* Re: A Java- / .NET-like monitorBonita Montero
|   | +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |`* Re: A Java- / .NET-like monitorBonita Montero
|   | | `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |  `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |+- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |`* Re: A Java- / .NET-like monitorBonita Montero
|   | |   | `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |  `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |+- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |`* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   | `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |  +- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |  `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |   `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |`* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    | `- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    +* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |`* Re: A Java- / .NET-like monitorPavel
|   | |   |   |    | `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |  `* Re: A Java- / .NET-like monitorPavel
|   | |   |   |    |   `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |    `* Re: A Java- / .NET-like monitorPavel
|   | |   |   |    |     +- Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     +* Re: A Java- / .NET-like monitorScott Lurndal
|   | |   |   |    |     |+* Re: A Java- / .NET-like monitorKaz Kylheku
|   | |   |   |    |     ||+- Re: A Java- / .NET-like monitorScott Lurndal
|   | |   |   |    |     ||+- Re: A Java- / .NET-like monitorPavel
|   | |   |   |    |     ||`* Re: A Java- / .NET-like monitorMichael S
|   | |   |   |    |     || `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||  `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||   `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||    +- Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||    `* Re: A Java- / .NET-like monitorScott Lurndal
|   | |   |   |    |     ||     `* Re: A Java- / .NET-like monitorKaz Kylheku
|   | |   |   |    |     ||      +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||      |`* Re: A Java- / .NET-like monitorScott Lurndal
|   | |   |   |    |     ||      | +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||      | |`- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||      | `* Re: A Java- / .NET-like monitorFred. Zwarts
|   | |   |   |    |     ||      |  `* Re: A Java- / .NET-like monitorScott Lurndal
|   | |   |   |    |     ||      |   `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||      |    `- Re: A Java- / .NET-like monitorScott Lurndal
|   | |   |   |    |     ||      +* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||      |`* Re: A Java- / .NET-like monitorKaz Kylheku
|   | |   |   |    |     ||      | `* Re: A Java- / .NET-like monitorScott Lurndal
|   | |   |   |    |     ||      |  +- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||      |  `* Re: A Java- / .NET-like monitorMichael S
|   | |   |   |    |     ||      |   +- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||      |   `* Re: A Java- / .NET-like monitorDavid Brown
|   | |   |   |    |     ||      |    +* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||      |    |+* Re: A Java- / .NET-like monitorDavid Brown
|   | |   |   |    |     ||      |    ||`* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||      |    || `* Re: A Java- / .NET-like monitorDavid Brown
|   | |   |   |    |     ||      |    ||  +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||      |    ||  |`- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||      |    ||  `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||      |    ||   `* Re: A Java- / .NET-like monitorDavid Brown
|   | |   |   |    |     ||      |    ||    `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||      |    ||     `* Re: A Java- / .NET-like monitorDavid Brown
|   | |   |   |    |     ||      |    ||      `- Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     ||      |    |`- Re: A Java- / .NET-like monitorScott Lurndal
|   | |   |   |    |     ||      |    `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     ||      |     `- Re: A Java- / .NET-like monitorDavid Brown
|   | |   |   |    |     ||      `- Re: A Java- / .NET-like monitorDavid Brown
|   | |   |   |    |     |+- Re: A Java- / .NET-like monitorPavel
|   | |   |   |    |     |`* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     | `* Re: A Java- / .NET-like monitorKaz Kylheku
|   | |   |   |    |     |  `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     |   `* Re: A Java- / .NET-like monitorKaz Kylheku
|   | |   |   |    |     |    `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     |     `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     |      +* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     |      |`- Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     |      `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     |       `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     |        `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     |         `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     |          `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     |           `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    |     |            `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   |    |     `* Re: A Java- / .NET-like monitorChris M. Thomasson
|   | |   |   |    `* Re: A Java- / .NET-like monitorBonita Montero
|   | |   |   `- Re: A Java- / .NET-like monitorBonita Montero
|   | |   `* Re: A Java- / .NET-like monitorPavel
|   | `* Re: A Java- / .NET-like monitorKaz Kylheku
|   `* Re: A Java- / .NET-like monitorChris M. Thomasson
+* Re: A Java- / .NET-like monitorBonita Montero
`* Re: A Java- / .NET-like monitorBonita Montero

Pages:1234567891011
Re: A Java- / .NET-like monitor

<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 07:47:09 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Nov 2023 06:47:08 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="3423016615fb0ec6903b0531fce55841";
logging-data="560222"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Rkc20BWIl/SmLP7n8/J2k9evrtQcR9qk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:9YUnEGt5ahqW3GxHT9ZW/kME00Y=
In-Reply-To: <uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
Content-Language: de-DE
 by: Bonita Montero - Mon, 13 Nov 2023 06:47 UTC

Sorry, the code worked, but I don't need an atomic:

#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <vector>

using namespace std;

int main( int argc, char **argv )
{ unsigned nProducers = jthread::hardware_concurrency() - 1;
if( (int)nProducers <= 0 )
return EXIT_FAILURE;
mutex mtx;
condition_variable cv;
constexpr uint64_t N_ITEMS = 10'000'000;
uint64_t itemOutput = 0;
auto producer = [&, inside = argc <= 1]()
{
static atomic_uint64_t itemCounter( 0 );
while( itemCounter.fetch_add( 1, memory_order_relaxed ) < N_ITEMS )
{
unique_lock lock( mtx );
++itemOutput;
if( inside )
cv.notify_one();
lock.unlock();
if( !inside )
cv.notify_one();
}
};
vector<jthread> procuders;
procuders.reserve( nProducers );
for( unsigned t = 0; t != nProducers; ++t )
procuders.emplace_back( producer );
uint64_t nextItem = 0;
for( ; ; )
{
unique_lock lock( mtx );
uint64_t lastItem;
while( (lastItem = itemOutput) < nextItem )
cv.wait( lock );
if( lastItem >= N_ITEMS )
break;
nextItem = lastItem;
}
}

It's early in the morning ...

Re: A Java- / .NET-like monitor

<GWq4N.33005$BbXa.8947@fx16.iad>

  copy mid

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

  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!fx16.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: A Java- / .NET-like monitor
Newsgroups: comp.lang.c++
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org> <uihnkd$21rae$1@dont-email.me> <uihnnm$21tq7$5@raubtier-asyl.eternal-september.org> <uihnup$21rab$4@dont-email.me> <uihpgl$227kv$1@raubtier-asyl.eternal-september.org> <nuT3N.20309$wvv7.18517@fx14.iad> <uipl56$3sugf$1@raubtier-asyl.eternal-september.org> <20231111205536.387@kylheku.com> <uiq7o0$1thb$1@raubtier-asyl.eternal-september.org> <Pi84N.104$ayBd.46@fx07.iad> <uisg2m$gsmo$2@raubtier-asyl.eternal-september.org>
Lines: 15
Message-ID: <GWq4N.33005$BbXa.8947@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 13 Nov 2023 15:05:10 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 13 Nov 2023 15:05:10 GMT
X-Received-Bytes: 1650
 by: Scott Lurndal - Mon, 13 Nov 2023 15:05 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 12.11.2023 um 18:53 schrieb Scott Lurndal:
>
>> No, you don't. If you updated the predicate that the condition
>> variable is monitoring while holding the mutex, you should release
>> the mutex before signaling or broadcasting the condition variable
>> to avoid unnecessary context switches.
>
>The context switch occurs only if _both_ conditions are met:
>the mutex is unlocked and the condition variable is signalled.

Ah, your not an expert on operating systems, it seems.

How would the OS know anything about the state of the mutex
associated with the condition variable?

Re: A Java- / .NET-like monitor

<uitfpt$mvco$1@raubtier-asyl.eternal-september.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 16:36:31 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uitfpt$mvco$1@raubtier-asyl.eternal-september.org>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<Pi84N.104$ayBd.46@fx07.iad>
<uisg2m$gsmo$2@raubtier-asyl.eternal-september.org>
<GWq4N.33005$BbXa.8947@fx16.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Nov 2023 15:36:29 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="3423016615fb0ec6903b0531fce55841";
logging-data="753048"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18weyMrS6xGUxn/FTHHxIDdYQkL7Ofn+7A="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:mN1u5XQ7fR4Xe2nV+hQl/V6BiU8=
In-Reply-To: <GWq4N.33005$BbXa.8947@fx16.iad>
Content-Language: de-DE
 by: Bonita Montero - Mon, 13 Nov 2023 15:36 UTC

Am 13.11.2023 um 16:05 schrieb Scott Lurndal:

> Ah, your not an expert on operating systems, it seems.

I've shown that my monitor has a slightly better performance than the
Linux mutex + condvar. So if they perform similar they dont have two
context switches for being signalled _and_ beging locked. Otherwise
the performance would be poorer.
And this code is not part of the kernel, but it used the kernel.

Re: A Java- / .NET-like monitor

<uitikn$ne6o$1@raubtier-asyl.eternal-september.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 17:24:57 +0100
Organization: A noiseless patient Spider
Lines: 105
Message-ID: <uitikn$ne6o$1@raubtier-asyl.eternal-september.org>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<Pi84N.104$ayBd.46@fx07.iad>
<uisg2m$gsmo$2@raubtier-asyl.eternal-september.org>
<GWq4N.33005$BbXa.8947@fx16.iad>
<uitfpt$mvco$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Nov 2023 16:24:55 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="3423016615fb0ec6903b0531fce55841";
logging-data="768216"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184XJkJ/ac6yah2nrw1FfyG5L/5dq+9Bd4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1p17DUfW3U97QWh9tLuv6hxPiZU=
In-Reply-To: <uitfpt$mvco$1@raubtier-asyl.eternal-september.org>
Content-Language: de-DE
 by: Bonita Montero - Mon, 13 Nov 2023 16:24 UTC

I've added some getrusage()s to take the number of voluntary context
switches. It's almost about the same for my monitor or a mutex and a
condvar under Linux. So the mutex plus condvar waits to be signalled
and released in one step, just as my monitor.

#include <iostream>
#include <thread>
#include <chrono>
#include <vector>
#include <mutex>
#include <condition_variable>
#include "monitor.h"
#if defined(__unix__)
#include <sys/resource.h>
#endif

using namespace std;
using namespace chrono;

int main( int argc, char **argv )
{ atomic_int64_t tSum;
#if defined(__unix__)
uint64_t lastVoluntary = 0;
auto voluntary = [&]()
{
rusage ru;
getrusage( RUSAGE_SELF, &ru );
uint64_t diff = ru.ru_nvcsw - lastVoluntary;
lastVoluntary = ru.ru_nvcsw;
return diff;
};
voluntary();
#endif
auto time = [&]( auto fn )
{
tSum = 0;
auto start = high_resolution_clock::now();
fn();
tSum += (int64_t)duration_cast<nanoseconds>(
high_resolution_clock::now() - start ).count();
};
constexpr size_t ROUNDS = 100'000;
struct not_t
{
monitor mon;
bool notifiy;
} notA { {}, true }, notB { {}, false };
notA.notifiy = true;
auto monThr = [&]( not_t &me, not_t &you )
{
time( [&]()
{
for( size_t r = ROUNDS; r; --r )
{
me.mon.lock();
for( ; !me.notifiy; me.mon.wait() );
me.notifiy = false;
me.mon.unlock();
you.mon.lock();
you.notifiy = true;
you.mon.notify();
you.mon.unlock();
}
} );
};
vector<jthread> threads;
threads.reserve( 0 );
threads.emplace_back( monThr, ref( notA ), ref( notB ) ),
threads.emplace_back( monThr, ref( notB ), ref( notA ) );
threads.resize( 0 );
cout << (double)tSum / (2.0 * ROUNDS) << endl;
#if defined(__unix__)
cout << "v: " << voluntary() << endl;
#endif
struct cv_t
{
mutex mtx;
condition_variable cv;
bool signal;
} cvA = { {}, {}, true }, cvB = { {}, {}, false };
auto cvThr = [&]( cv_t &cvMe, cv_t &cvYou )
{
time( [&]()
{
for( size_t r = ROUNDS; r; --r )
{
unique_lock<mutex> lockMe( cvMe.mtx );
for( ; !cvMe.signal; cvMe.cv.wait( lockMe ) );
cvMe.signal = false;
lockMe.unlock();
unique_lock<mutex> lockYou( cvYou.mtx );
cvYou.signal = true;
cvYou.cv.notify_one();
}
} );
};
threads.emplace_back( cvThr, ref( cvA ), ref( cvB ) );
threads.emplace_back( cvThr, ref( cvB ), ref( cvA ) );
threads.resize( 0 );
cout << (double)tSum / (2.0 * ROUNDS) << endl;
#if defined(__unix__)
cout << "v: " << voluntary() << endl;
#endif
}

Re: A Java- / .NET-like monitor

<uiu26e$sper$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 12:50:22 -0800
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <uiu26e$sper$1@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Nov 2023 20:50:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="55c5ba4d49df2a7646321f8f0cd32f12";
logging-data="943579"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19TYYMq/9mK1s/4aJwy99xho3ZkM7ELrfw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LpOa5XhEzwd3SdcSwi1KP0OEhFc=
In-Reply-To: <uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 13 Nov 2023 20:50 UTC

On 11/12/2023 10:47 PM, Bonita Montero wrote:
> Sorry, the code worked, but I don't need an atomic:
[...]
> It's early in the morning ...

Yawn. Why not make sure it works _first_!?

Re: A Java- / .NET-like monitor

<uiu860$tarm$4@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 14:32:32 -0800
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <uiu860$tarm$4@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com> <E5e4N.6986$Ubzd.3639@fx36.iad>
<20231112203949.483@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Nov 2023 22:32:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="55c5ba4d49df2a7646321f8f0cd32f12";
logging-data="961398"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NomeG+paTAduI3Zo1EizjSgAWgI87wxw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UFDUBv0RzzODaILLpI6qC/3Q2/c=
Content-Language: en-US
In-Reply-To: <20231112203949.483@kylheku.com>
 by: Chris M. Thomasson - Mon, 13 Nov 2023 22:32 UTC

On 11/12/2023 8:48 PM, Kaz Kylheku wrote:
> On 2023-11-13, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote:
>> Kaz Kylheku wrote:
>>> If you're using POSIX mutexes and conditions, you should call
>>> pthread_cond_signal and pthread_cond_broadcast outside of the mutex,
>>> whenever possible.
>> This is recommended against by the standard for the same reason why Java
>> implements Hoare monitor behavior. Citation:
>>
>> "
>> The pthread_cond_broadcast() or pthread_cond_signal() functions may be
>> called by a thread whether or not it currently owns the mutex that
>> threads calling pthread_cond_wait() or pthread_cond_timedwait() have
>> associated with the condition variable during their waits; however, if
>> predictable scheduling behavior is required, then that mutex shall be
>> locked by the thread calling pthread_cond_broadcast() or
>> pthread_cond_signal().
>> "
>
> But that text is stupid/defective, because you will not actually get
> predictable scheduling behavior just by doing that.
>
> Signal the condition while still holding the mutex doesn't give you any
> guarantees about which thread will get the mutex next.
>
> Suppose:
>
> 1. The signal operation wake up the next waiting thread.
>
> 2. The signaler then gives up the mutex.
>
> 3. Before that awoken next-waiting-thread gets the mutex, some
> another thread comes along and seizes the mutex.
>
> Signaling in the mutex can blow up the critical region from "handful of
> instructions" to "hundreds of instructions".
>
> If we compare:
>
> mutex_lock(&stack->lock);
> node->next = stack->top;
> stack->top = node;
> mutex_unlock(&stack->lock);
>
> cond_signal(&stack->item_pushed);
>
> All that is in the critical region are the mutex are the list
> manipulation instructions, plus some of the mutex code itself.
>
> If we move cond_signal before mutex_unlock, everything done by that
> function, including potentially going into the kernel to wake up a
> thread, is now in the mutex.

Excellent point. DING!

>
> That's a lot to pay for some vague, unfulfillable promise of
> "predictable scheduling behavior", on which you can base approximately
> nothing.
>
> Hoare semantics gives you something: that if there are waiting tasks
> queued on a condition, the monitor is transferred to the first waiting
> one. *And* (I seem to recall) when that thread leaves the monitor, the
> original signaler gets it again!
>

Re: A Java- / .NET-like monitor

<_WA4N.30669$_Oab.744@fx15.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
Subject: Re: A Java- / .NET-like monitor
Newsgroups: comp.lang.c++
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com> <E5e4N.6986$Ubzd.3639@fx36.iad>
<20231112203949.483@kylheku.com>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
MIME-Version: 1.0
In-Reply-To: <20231112203949.483@kylheku.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 44
Message-ID: <_WA4N.30669$_Oab.744@fx15.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 14 Nov 2023 02:28:10 UTC
Date: Mon, 13 Nov 2023 21:27:53 -0500
X-Received-Bytes: 3678
 by: Pavel - Tue, 14 Nov 2023 02:27 UTC

Kaz Kylheku wrote:
> On 2023-11-13, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote:
>> Kaz Kylheku wrote:
>>> If you're using POSIX mutexes and conditions, you should call
>>> pthread_cond_signal and pthread_cond_broadcast outside of the mutex,
>>> whenever possible.
>> This is recommended against by the standard for the same reason why Java
>> implements Hoare monitor behavior. Citation:
>>
>> "
>> The pthread_cond_broadcast() or pthread_cond_signal() functions may be
>> called by a thread whether or not it currently owns the mutex that
>> threads calling pthread_cond_wait() or pthread_cond_timedwait() have
>> associated with the condition variable during their waits; however, if
>> predictable scheduling behavior is required, then that mutex shall be
>> locked by the thread calling pthread_cond_broadcast() or
>> pthread_cond_signal().
>> "
>
> But that text is stupid/defective, because you will not actually get
> predictable scheduling behavior just by doing that.

This is POSIX text that IIRC was a compromise with real-time (RT) guys.
Java has thread priorities so it is formally relevant (could be relevant
in some implementations, too; did not really check). RT guys don't like
condvars in principle as they are a "gateway drug" to all kinds of prio
inversions so this was a compromise that permitted the condvar to get to
POSIX. The meaning of the spec is to prevent priority inversion when
running on one CPU. An example problematic scenario is as follows:

1. Higher-prio thread A grabs mutex and starts waiting for an event
(say, posted to a queue that's currently empty). The mutex is released
at this time to allow posting the event (the standard behavior of
pthread_cond_wait()).
2. Now that the A is not runnable, a lower-prio thread B can also run
and suppose it also wants event from same queue.
3. Thread C grabs mutex, posts event to the queue, releases the mutex
4. Before thread C manages to signal the condvar (and by that wake up
thread A), thread B grabs the lock and steals the event. Higher-prio
thread A stays waiting for the event -- which is what RT guys hate.

With the behavior recommended by the standard, thread C will first
notify condvar, by that making thread A runnable and thread A will grab
the event.

Re: A Java- / .NET-like monitor

<6nB4N.2145$qqwd.2132@fx42.iad>

  copy mid

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

  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!fx42.iad.POSTED!not-for-mail
Subject: Re: A Java- / .NET-like monitor
Newsgroups: comp.lang.c++
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com> <E5e4N.6986$Ubzd.3639@fx36.iad>
<20231112203949.483@kylheku.com>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
MIME-Version: 1.0
In-Reply-To: <20231112203949.483@kylheku.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 94
Message-ID: <6nB4N.2145$qqwd.2132@fx42.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 14 Nov 2023 02:58:10 UTC
Date: Mon, 13 Nov 2023 21:58:10 -0500
X-Received-Bytes: 5490
 by: Pavel - Tue, 14 Nov 2023 02:58 UTC

Kaz Kylheku wrote:
> On 2023-11-13, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote:
>> Kaz Kylheku wrote:
>>> If you're using POSIX mutexes and conditions, you should call
>>> pthread_cond_signal and pthread_cond_broadcast outside of the mutex,
>>> whenever possible.
>> This is recommended against by the standard for the same reason why Java
>> implements Hoare monitor behavior. Citation:
>>
>> "
>> The pthread_cond_broadcast() or pthread_cond_signal() functions may be
>> called by a thread whether or not it currently owns the mutex that
>> threads calling pthread_cond_wait() or pthread_cond_timedwait() have
>> associated with the condition variable during their waits; however, if
>> predictable scheduling behavior is required, then that mutex shall be
>> locked by the thread calling pthread_cond_broadcast() or
>> pthread_cond_signal().
>> "
>
> But that text is stupid/defective, because you will not actually get
> predictable scheduling behavior just by doing that.
>
> Signal the condition while still holding the mutex doesn't give you any
> guarantees about which thread will get the mutex next.
>
> Suppose:
>
> 1. The signal operation wake up the next waiting thread.
>
> 2. The signaler then gives up the mutex.
>
> 3. Before that awoken next-waiting-thread gets the mutex, some
> another thread comes along and seizes the mutex.
This is a gray area, the specs says:

When each thread unblocked as a result of a pthread_cond_broadcast() or
pthread_cond_signal() returns from its call to
pthread_cond_wait() or pthread_cond_timedwait(), the thread shall own
the mutex with which it called pthread_cond_wait() or
pthread_cond_timedwait(). The thread(s) that are un‐
blocked shall contend for the mutex according to the scheduling
policy (if applicable), and as if each had called pthread_mutex_lock().

"as-if" and "according to the scheduling policy (if applicable)" here
are important. The standard intent may be to permit only the threads
that are "unblocked" contend for the mutex -- as opposed to all
non-blocked threads. In other words, it is feasible reading of the
standard that, if the pthread_cond_signal caller owns the mutex, as
recommended, the scheduler may, within the signal call, get the threads
being unblocked "to the beginning of the line (queue) of the contenders
for the mutex" before the signalling thread has a chance to do anything
(in particular, release the mutex). Then another thread has no chance of
seizing the mutex.

>
> Signaling in the mutex can blow up the critical region from "handful of
> instructions" to "hundreds of instructions".
RT is all about discipline to achieve low latency of serving some
requests. It is not about high throughput.

In fact, implementing ANY scheduling policy, even simple FIFO (although
even defining a FIFO policy on a multi-CPU system is not as simple),
incurs costs as compared to "no policy". RT policies are even more
expensive. For some systems they make sense, for some they don't. POSIX
threads extension was worked on largely in parallel with RT extension
and this shows in the product.

>
> If we compare:
>
> mutex_lock(&stack->lock);
> node->next = stack->top;
> stack->top = node;
> mutex_unlock(&stack->lock);
>
> cond_signal(&stack->item_pushed);
>
> All that is in the critical region are the mutex are the list
> manipulation instructions, plus some of the mutex code itself.
>
> If we move cond_signal before mutex_unlock, everything done by that
> function, including potentially going into the kernel to wake up a
> thread, is now in the mutex.
>
> That's a lot to pay for some vague, unfulfillable promise of
> "predictable scheduling behavior", on which you can base approximately
> nothing.
>
> Hoare semantics gives you something: that if there are waiting tasks
> queued on a condition, the monitor is transferred to the first waiting
> one. *And* (I seem to recall) when that thread leaves the monitor, the
> original signaler gets it again!
>

Re: A Java- / .NET-like monitor

<euB4N.6863$%p%e.3900@fx43.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx43.iad.POSTED!not-for-mail
Subject: Re: A Java- / .NET-like monitor
Newsgroups: comp.lang.c++
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<Pi84N.104$ayBd.46@fx07.iad> <b9e4N.20671$Ee89.15587@fx17.iad>
<20231112204849.10@kylheku.com>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
MIME-Version: 1.0
In-Reply-To: <20231112204849.10@kylheku.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 24
Message-ID: <euB4N.6863$%p%e.3900@fx43.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 14 Nov 2023 03:05:46 UTC
Date: Mon, 13 Nov 2023 22:05:46 -0500
X-Received-Bytes: 2470
 by: Pavel - Tue, 14 Nov 2023 03:05 UTC

Kaz Kylheku wrote:
> On 2023-11-13, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote:
>> Scott Lurndal wrote:
>>> No, you don't. If you updated the predicate that the condition
>>> variable is monitoring while holding the mutex, you should release
>>> the mutex before signaling or broadcasting the condition variable
>>> to avoid unnecessary context switches.
>>>
>> Why would you have additional context switches if you signal before
>> releasing the lock?
>
> Because of the situation that the thread which was signaled is
> trying to acquire the mutex, which, stupidly, the signaling thread
> is still holding. So, oops, back it goes into suspended state, and we
> have to context switch to the mutex holder which has to release the
> mutex and then switch to that signaled thread again.
>
Please see my response to your other post. "as-if" calling of
pthread_mutex_lock does not prescribe actually calling it. Nothing in
the standard prevents pthread_cond_signal from doing all the job of
stuffing the unblocked threads to the mutex waiting list in accordance
with some scheduling policy. They don't really need to leave the
non-runnable state until the mutex is released.

Re: A Java- / .NET-like monitor

<20231113191446.974@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Tue, 14 Nov 2023 03:27:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20231113191446.974@kylheku.com>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com> <E5e4N.6986$Ubzd.3639@fx36.iad>
<20231112203949.483@kylheku.com> <6nB4N.2145$qqwd.2132@fx42.iad>
Injection-Date: Tue, 14 Nov 2023 03:27:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d3fbbbd1acebca204049aab1d0d01135";
logging-data="1163759"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/da8i9+psRXhsctcg/7W+9dCMXs5GHmpM="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:Hgu/DGl2JFKCBDAXGqWGTPq7moc=
 by: Kaz Kylheku - Tue, 14 Nov 2023 03:27 UTC

On 2023-11-14, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote:
> "as-if" and "according to the scheduling policy (if applicable)" here
> are important. The standard intent may be to permit only the threads
> that are "unblocked" contend for the mutex -- as opposed to all
> non-blocked threads.

It's possible that only one thread is unblocked by a
pthread_cond_signal. It takes at least two parties to contend for
something.

--
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: A Java- / .NET-like monitor

<20231113192822.953@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Tue, 14 Nov 2023 03:30:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <20231113192822.953@kylheku.com>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<Pi84N.104$ayBd.46@fx07.iad> <b9e4N.20671$Ee89.15587@fx17.iad>
<20231112204849.10@kylheku.com> <euB4N.6863$%p%e.3900@fx43.iad>
Injection-Date: Tue, 14 Nov 2023 03:30:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d3fbbbd1acebca204049aab1d0d01135";
logging-data="1163759"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19a/9Xfqm/iyYkINmC4C0Ws729NIIdvxpo="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:c1WEh9IFKIcB9bxCeZviUxo1Xv4=
 by: Kaz Kylheku - Tue, 14 Nov 2023 03:30 UTC

On 2023-11-14, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote:
> Kaz Kylheku wrote:
>> Because of the situation that the thread which was signaled is
>> trying to acquire the mutex, which, stupidly, the signaling thread
>> is still holding. So, oops, back it goes into suspended state, and we
>> have to context switch to the mutex holder which has to release the
>> mutex and then switch to that signaled thread again.
>>
> Please see my response to your other post. "as-if" calling of
> pthread_mutex_lock does not prescribe actually calling it. Nothing in
> the standard prevents pthread_cond_signal from doing all the job of
> stuffing the unblocked threads to the mutex waiting list in accordance
> with some scheduling policy.

Have you noticed how no mutex appears in the pthread_cond_signal API?

--
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: A Java- / .NET-like monitor

<uiv020$148s1$1@raubtier-asyl.eternal-september.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Tue, 14 Nov 2023 06:20:03 +0100
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <uiv020$148s1$1@raubtier-asyl.eternal-september.org>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 05:20:00 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="638e4d8f863cffbb5f955914b4bbf384";
logging-data="1188737"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xh8F9QSHbWHB/3tWmSaOcIuIQnXRkurQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:kIiWnejMJ3xvWFwmaKDkIcSAwEE=
Content-Language: de-DE
In-Reply-To: <uiu26e$sper$1@dont-email.me>
 by: Bonita Montero - Tue, 14 Nov 2023 05:20 UTC

Am 13.11.2023 um 21:50 schrieb Chris M. Thomasson:
> On 11/12/2023 10:47 PM, Bonita Montero wrote:
>> Sorry, the code worked, but I don't need an atomic:
> [...]
>> It's early in the morning ...
>
> Yawn. Why not make sure it works _first_!?

The first code worked but the atomic could be a normal uint64_t
since its access is surrounded by a mutex lock and unlock.

Re: A Java- / .NET-like monitor

<uiv050$1462e$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 21:21:35 -0800
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <uiv050$1462e$1@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
<uiv020$148s1$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 05:21:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1185870"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NhYADAYf0Ftha+hGHIorx0imRHr80QYM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:obzld2EEKxNAitJdOr9dGBk2r9E=
Content-Language: en-US
In-Reply-To: <uiv020$148s1$1@raubtier-asyl.eternal-september.org>
 by: Chris M. Thomasson - Tue, 14 Nov 2023 05:21 UTC

On 11/13/2023 9:20 PM, Bonita Montero wrote:
> Am 13.11.2023 um 21:50 schrieb Chris M. Thomasson:
>> On 11/12/2023 10:47 PM, Bonita Montero wrote:
>>> Sorry, the code worked, but I don't need an atomic:
>> [...]
>>> It's early in the morning ...
>>
>> Yawn. Why not make sure it works _first_!?
>
> The first code worked but the atomic could be a normal uint64_t
> since its access is surrounded by a mutex lock and unlock.
>

You mean a word wrt the arch, or uint64_t on a 32-bit system?

Re: A Java- / .NET-like monitor

<uiv0ib$149hi$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 21:28:43 -0800
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <uiv0ib$149hi$1@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com> <E5e4N.6986$Ubzd.3639@fx36.iad>
<20231112203949.483@kylheku.com> <6nB4N.2145$qqwd.2132@fx42.iad>
<20231113191446.974@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 05:28:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1189426"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ude6D8EEQDU4aIETr11ncyMgU5LLx6a8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:r10BXaaoORiYxv7UDXFZAXZLzqI=
Content-Language: en-US
In-Reply-To: <20231113191446.974@kylheku.com>
 by: Chris M. Thomasson - Tue, 14 Nov 2023 05:28 UTC

On 11/13/2023 7:27 PM, Kaz Kylheku wrote:
> On 2023-11-14, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote:
>> "as-if" and "according to the scheduling policy (if applicable)" here
>> are important. The standard intent may be to permit only the threads
>> that are "unblocked" contend for the mutex -- as opposed to all
>> non-blocked threads.
>
> It's possible that only one thread is unblocked by a
> pthread_cond_signal. It takes at least two parties to contend for
> something.
>

A signalling thread does its thing while holding the mutex... Well, it
hears the following playing in the background:

https://youtu.be/7YvAYIJSSZY

Re: A Java- / .NET-like monitor

<uiv0k9$149hi$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 21:29:45 -0800
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <uiv0k9$149hi$2@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com> <E5e4N.6986$Ubzd.3639@fx36.iad>
<20231112203949.483@kylheku.com> <6nB4N.2145$qqwd.2132@fx42.iad>
<20231113191446.974@kylheku.com> <uiv0ib$149hi$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 05:29:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1189426"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rh3MdybhJMZcOcXLF2ufNt926nNKoCEg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UsKlIq+ZsVQziLHLtPZR5FEVCCA=
In-Reply-To: <uiv0ib$149hi$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 14 Nov 2023 05:29 UTC

On 11/13/2023 9:28 PM, Chris M. Thomasson wrote:
> On 11/13/2023 7:27 PM, Kaz Kylheku wrote:
>> On 2023-11-14, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>
>> wrote:
>>> "as-if" and "according to the scheduling policy (if applicable)" here
>>> are important. The standard intent may be to permit only the threads
>>> that are "unblocked" contend for the mutex -- as opposed to all
>>> non-blocked threads.
>>
>> It's possible that only one thread is unblocked by a
>> pthread_cond_signal. It takes at least two parties to contend for
>> something.
>>
>
> A signalling thread does its thing while holding the mutex... Well, it
> hears the following playing in the background:
>
> https://youtu.be/7YvAYIJSSZY

A condvar that cannot signal/broadcast from outside of a held mutex is
broken by default.

Re: A Java- / .NET-like monitor

<uiv4fh$14o4p$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 22:35:29 -0800
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <uiv4fh$14o4p$1@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<Pi84N.104$ayBd.46@fx07.iad> <b9e4N.20671$Ee89.15587@fx17.iad>
<20231112204849.10@kylheku.com> <euB4N.6863$%p%e.3900@fx43.iad>
<20231113192822.953@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 06:35:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1204377"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YU7FHBqrihpxlVZALHw4Db5ZBIinANgQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:5B/Df3HMmpj2Z2f13k/kGc3huOA=
Content-Language: en-US
In-Reply-To: <20231113192822.953@kylheku.com>
 by: Chris M. Thomasson - Tue, 14 Nov 2023 06:35 UTC

On 11/13/2023 7:30 PM, Kaz Kylheku wrote:
> On 2023-11-14, Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote:
>> Kaz Kylheku wrote:
>>> Because of the situation that the thread which was signaled is
>>> trying to acquire the mutex, which, stupidly, the signaling thread
>>> is still holding. So, oops, back it goes into suspended state, and we
>>> have to context switch to the mutex holder which has to release the
>>> mutex and then switch to that signaled thread again.
>>>
>> Please see my response to your other post. "as-if" calling of
>> pthread_mutex_lock does not prescribe actually calling it. Nothing in
>> the standard prevents pthread_cond_signal from doing all the job of
>> stuffing the unblocked threads to the mutex waiting list in accordance
>> with some scheduling policy.
>
> Have you noticed how no mutex appears in the pthread_cond_signal API?
>

DING!

Re: A Java- / .NET-like monitor

<uiv50o$14quu$1@raubtier-asyl.eternal-september.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Tue, 14 Nov 2023 07:44:43 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uiv50o$14quu$1@raubtier-asyl.eternal-september.org>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
<uiv020$148s1$1@raubtier-asyl.eternal-september.org>
<uiv050$1462e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 06:44:40 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="638e4d8f863cffbb5f955914b4bbf384";
logging-data="1207262"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18y5P/L8PZgx6oKSD2aHrbUqrm4OQa79u8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:fInuVyZXZt6iwDjeOAV+/Hy3hYs=
In-Reply-To: <uiv050$1462e$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Tue, 14 Nov 2023 06:44 UTC

Am 14.11.2023 um 06:21 schrieb Chris M. Thomasson:

> You mean a word wrt the arch, or uint64_t on a 32-bit system?

itemOutput first was a atomic_uint64_t and now is a uint64_t.
The atomicwasn't necessary because itemOutput is accessed within
a mutex access, i.e. it is surrounded with a lock() and unlock()
which itself have a acquire and release behaviour, so I itemOutput
doesn't need to be atomic.

Re: A Java- / .NET-like monitor

<uiv544$14o4p$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 22:46:27 -0800
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <uiv544$14o4p$2@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<uinloo$3d813$1@raubtier-asyl.eternal-september.org>
<uiolcu$3j4r2$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 14 Nov 2023 06:46:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1204377"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gLS0mt5aKU+nV4/N8LCU0ktWNRejgY7A="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:WOdO1tUgrQMoEeOAYJUtI+3Vcok=
In-Reply-To: <uiolcu$3j4r2$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 14 Nov 2023 06:46 UTC

On 11/11/2023 11:41 AM, Chris M. Thomasson wrote:
> On 11/11/2023 2:41 AM, Bonita Montero wrote:
>> I think I've put the finishing touches to the code now. For the mutex
>> part I introduced spinning, which I adopted from glibc. Spinning usually
> [...]
>
> Food for thought... I learned something really neat over on comp.arch
> wrt Lynn Wheeler many years ago. Basically, why spin doing nothing? Oh,
> you use a yield... Well, that is still doing nothing. Think of a spin
> along the lines of:
>
> we try to use accomplished work as a backoff/yield for a spin...
>
>
> <quick pseudo-code>
> ______________
> void lock()
> {
>   while (! mutex_trylock())
>   {
>     // try to do some "other" work as a
>     // yield, in a sense... Hummm.... ;^)
>     if (! try_to_do_some__other__work())
>     {
>         // failed to do some other work, lock it...
>     mutex_lock();
>         break;
>     }
>   }
>
>   // we are locked! =^D
> }
>
> void unlock()
> {
>   mutex_unlock();
> }
> ______________
>
>
> Well, this can be beneficial in certain setups...

Train Control... Can other work be done instead of spinning on a
spinlock? Humm...

https://youtu.be/Gm0NWMdcbmU

Re: A Java- / .NET-like monitor

<uiv5d2$14o4p$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 22:51:13 -0800
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <uiv5d2$14o4p$3@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
<uiv020$148s1$1@raubtier-asyl.eternal-september.org>
<uiv050$1462e$1@dont-email.me>
<uiv50o$14quu$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 06:51:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1204377"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BN/Cwya/IrF8Jrl2puFq8b2yRG0KZZcs="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8BFdUvPGM46FroVmdY+crEEe42w=
Content-Language: en-US
In-Reply-To: <uiv50o$14quu$1@raubtier-asyl.eternal-september.org>
 by: Chris M. Thomasson - Tue, 14 Nov 2023 06:51 UTC

On 11/13/2023 10:44 PM, Bonita Montero wrote:
> Am 14.11.2023 um 06:21 schrieb Chris M. Thomasson:
>
>> You mean a word wrt the arch, or uint64_t on a 32-bit system?
>
> itemOutput first was a atomic_uint64_t and now is a uint64_t.
> The atomicwasn't necessary because itemOutput is accessed within
> a mutex access, i.e. it is surrounded with a lock() and unlock()
> which itself have a acquire and release behaviour, so I itemOutput
> doesn't need to be atomic.
>

If you say so. I have not had enough time to study up on your code. Btw,
are you finished with any bug fixes? Are you sure it might not have any
spinning out of control aspects to it? If I do model it, we need to get
to a concrete version of it, you say this is it, I say okay, call it
BonitaMonitorVersion1. Fair enough?

https://youtu.be/T_U3Zdv8to8

Re: A Java- / .NET-like monitor

<uiv5l2$14tnc$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 22:55:30 -0800
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <uiv5l2$14tnc$1@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
<uiv020$148s1$1@raubtier-asyl.eternal-september.org>
<uiv050$1462e$1@dont-email.me>
<uiv50o$14quu$1@raubtier-asyl.eternal-september.org>
<uiv5d2$14o4p$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 06:55:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1210092"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lfsDzuCgwL6r+X983Z1jgkyhXJ38VFXg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ts241Y128yguW+6+XaPLNYedRQY=
In-Reply-To: <uiv5d2$14o4p$3@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 14 Nov 2023 06:55 UTC

On 11/13/2023 10:51 PM, Chris M. Thomasson wrote:
> On 11/13/2023 10:44 PM, Bonita Montero wrote:
>> Am 14.11.2023 um 06:21 schrieb Chris M. Thomasson:
>>
>>> You mean a word wrt the arch, or uint64_t on a 32-bit system?
>>
>> itemOutput first was a atomic_uint64_t and now is a uint64_t.
>> The atomicwasn't necessary because itemOutput is accessed within
>> a mutex access, i.e. it is surrounded with a lock() and unlock()
>> which itself have a acquire and release behaviour, so I itemOutput
>> doesn't need to be atomic.
>>
>
> If you say so. I have not had enough time to study up on your code. Btw,
> are you finished with any bug fixes? Are you sure it might not have any
> spinning out of control aspects to it? If I do model it, we need to get
> to a concrete version of it, you say this is it, I say okay, call it
> BonitaMonitorVersion1. Fair enough?
>
> https://youtu.be/T_U3Zdv8to8

Put your version that you know works up in github or something. Name it,
then I can get to work on it. I don't want to hear about any bug fixes
as I am porting it over to a Relacy test unit. Fair enough? Say THIS IS IT!

https://youtu.be/U8SSdyflGN4

Done. Then, we can get to work.

Re: A Java- / .NET-like monitor

<uiv5u6$14umb$1@raubtier-asyl.eternal-september.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Tue, 14 Nov 2023 08:00:25 +0100
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <uiv5u6$14umb$1@raubtier-asyl.eternal-september.org>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108100351.347@kylheku.com>
<uigk5o$1nmku$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
<uiv020$148s1$1@raubtier-asyl.eternal-september.org>
<uiv050$1462e$1@dont-email.me>
<uiv50o$14quu$1@raubtier-asyl.eternal-september.org>
<uiv5d2$14o4p$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 07:00:22 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="638e4d8f863cffbb5f955914b4bbf384";
logging-data="1211083"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KFkenK4CENy2m1HFQSow9PrxLY6RO2iQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:lsFTXKYoizetIXp2+Z3yVdQo47A=
Content-Language: de-DE
In-Reply-To: <uiv5d2$14o4p$3@dont-email.me>
 by: Bonita Montero - Tue, 14 Nov 2023 07:00 UTC

Am 14.11.2023 um 07:51 schrieb Chris M. Thomasson:

> If you say so. I have not had enough time to study up on your code. Btw,
> are you finished with any bug fixes? Are you sure it might not have any
> spinning out of control aspects to it? If I do model it, we need to get
> to a concrete version of it, you say this is it, I say okay, call it
> BonitaMonitorVersion1. Fair enough?

I've got a class thead_queue which I used for years. I changed it to
use my monitor instead a mutex plus condition variable. And the thead
_queue is used a lot and the code that used it works as before. That's
so much randomized synchronization for that that I for sure don't need
any Ralacy or whatever.

Re: A Java- / .NET-like monitor

<uiv6b6$150ur$1@raubtier-asyl.eternal-september.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Tue, 14 Nov 2023 08:07:20 +0100
Organization: A noiseless patient Spider
Lines: 186
Message-ID: <uiv6b6$150ur$1@raubtier-asyl.eternal-september.org>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
<uiv020$148s1$1@raubtier-asyl.eternal-september.org>
<uiv050$1462e$1@dont-email.me>
<uiv50o$14quu$1@raubtier-asyl.eternal-september.org>
<uiv5d2$14o4p$3@dont-email.me>
<uiv5u6$14umb$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 07:07:18 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="638e4d8f863cffbb5f955914b4bbf384";
logging-data="1213403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mwfNO21QcvaMdImsoiMTcFqoKP2X/FdU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:OvZX3ejFAbhnRKfunv2iWrxVQlE=
In-Reply-To: <uiv5u6$14umb$1@raubtier-asyl.eternal-september.org>
Content-Language: de-DE
 by: Bonita Montero - Tue, 14 Nov 2023 07:07 UTC

Am 14.11.2023 um 08:00 schrieb Bonita Montero:
> Am 14.11.2023 um 07:51 schrieb Chris M. Thomasson:
>
>> If you say so. I have not had enough time to study up on your code.
>> Btw, are you finished with any bug fixes? Are you sure it might not
>> have any spinning out of control aspects to it? If I do model it, we
>> need to get to a concrete version of it, you say this is it, I say
>> okay, call it BonitaMonitorVersion1. Fair enough?
>
> I've got a class thead_queue ...

This is my thread_queue in the version where I didn't use my monitor:

#pragma once
#include <deque>
#include <mutex>
#include <condition_variable>
#include <utility>
#include <concepts>
#include <list>
#include <deque>
#include "invoke_on_destruct.h"

template<typename Entity, typename Allocator = std::allocator<Entity>>
struct thread_queue
{ thread_queue();
explicit thread_queue( Allocator const &alloc );
thread_queue( thread_queue const & ) = delete;
thread_queue( thread_queue &&other );
thread_queue &operator =( thread_queue const & ) = delete;
thread_queue &operator =( thread_queue &&other );
bool empty() const;
size_t size() const;
void shrink_to_fit();
void clear();
template<typename ... Args>
requires std::is_constructible_v<Entity, Args ...>
void enque( Args &&... args );
template<typename Producer>
requires requires( Producer producer ) { { producer() } ->
std::same_as<std::pair<bool, Entity>>; }
void enqueue_multiple( Producer producer );
template<typename Consumer>
requires requires( Consumer consumer, Entity value ) { { consumer(
std::move( value ) ) } -> std::same_as<bool>; }
|| requires( Consumer consumer, size_t remaining, Entity value ) { {
consumer( remaining, std::move( value ) ) } -> std::same_as<bool>; }
void dequeue_multiple( Consumer consumer );
Entity dequeue();
std::deque<Entity, Allocator> deque();
private:
mutable std::mutex m_mtx;
mutable std::condition_variable m_cv;
std::deque<Entity, Allocator> m_queue;
};

template<typename Entity, typename Allocator>
thread_queue<Entity, Allocator>::thread_queue()
{ }

template<typename Entity, typename Allocator>
thread_queue<Entity, Allocator>::thread_queue( Allocator const &alloc ) :
m_queue( alloc )
{ }

template<typename Entity, typename Allocator>
thread_queue<Entity, Allocator>::thread_queue( thread_queue &&other )
{ std::scoped_lock lock( m_mtx );
m_queue = move( other.m_queue );
}

template<typename Entity, typename Allocator>
thread_queue<Entity, Allocator> &thread_queue<Entity,
Allocator>::thread_queue::operator =( thread_queue &&other )
{ using namespace std;
lock_guard
ourlock( m_mtx ),
otherLock( other.m_mon );
m_queue = move( other.m_queue );
return *this;
}

template<typename Entity, typename Allocator>
bool thread_queue<Entity, Allocator>::thread_queue::empty() const
{ std::lock_guard lock( m_mtx );
return m_queue.empty();
}

template<typename Entity, typename Allocator>
size_t thread_queue<Entity, Allocator>::thread_queue::size() const
{ std::lock_guard lock( m_mtx );
return m_queue.size();
}

template<typename Entity, typename Allocator>
void thread_queue<Entity, Allocator>::thread_queue::shrink_to_fit()
{ std::lock_guard lock( m_mtx );
return m_queue.shrink_to_fit();
}

template<typename Entity, typename Allocator>
void thread_queue<Entity, Allocator>::thread_queue::clear()
{ std::lock_guard lock( m_mtx );
m_queue.clear();
}

template<typename Entity, typename Allocator>
template<typename ... Args>
requires std::is_constructible_v<Entity, Args ...>
void thread_queue<Entity, Allocator>::thread_queue::enque( Args &&... args )
{ using namespace std;
unique_lock lock( m_mtx );
m_queue.emplace_front( forward<Args>( args ) ... );
m_cv.notify_one();
}

template<typename Entity, typename Allocator>
Entity thread_queue<Entity, Allocator>::thread_queue::dequeue()
{ using namespace std;
unique_lock lock( m_mtx );
while( m_queue.empty() )
m_cv.wait( lock );
Entity value = move( m_queue.back() );
m_queue.pop_back();
return value;
}

template<typename Entity, typename Allocator>
template<typename Producer>
requires requires( Producer producer ) { { producer() } ->
std::same_as<std::pair<bool, Entity>>; }
void thread_queue<Entity, Allocator>::enqueue_multiple( Producer producer )
{ using namespace std;
lock_guard lock( m_mtx );
for( pair<bool, Entity> ret; (ret = move( producer() )).first; )
m_queue.emplace_front( move( ret.second ) ),
m_cv.notify_one();
}

template<typename Entity, typename Allocator>
template<typename Consumer>
requires requires( Consumer consumer, Entity value ) { { consumer(
std::move( value ) ) } -> std::same_as<bool>; }
|| requires( Consumer consumer, size_t remaining, Entity value ) { {
consumer( remaining, std::move( value ) ) } -> std::same_as<bool>; }
void thread_queue<Entity, Allocator>::dequeue_multiple( Consumer consumer )
{ using namespace std;
unique_lock lock( m_mtx );
for( ; ; )
{
while( m_queue.empty() )
m_cv.wait( lock );
invoke_on_destruct popBack( [&]() { m_queue.pop_back(); } );
if constexpr( requires( Consumer consumer, Entity value ) { {
consumer( std::move( value ) ) } -> std::same_as<bool>; } )
if( !consumer( move( m_queue.back() ) ) )
return;
else;
else
if( !consumer( m_queue.size(), move( m_queue.back() ) ) )
return;
}
}

template<typename Entity, typename Allocator>
std::deque<Entity, Allocator> thread_queue<Entity, Allocator>::deque()
{ using namespace std;
unique_lock lock( m_mtx );
return move( m_queue );
}

Concepts rock !

Re: A Java- / .NET-like monitor

<uiv6cf$14tnc$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 23:07:58 -0800
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <uiv6cf$14tnc$2@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<20231108114723.256@kylheku.com>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
<uiv020$148s1$1@raubtier-asyl.eternal-september.org>
<uiv050$1462e$1@dont-email.me>
<uiv50o$14quu$1@raubtier-asyl.eternal-september.org>
<uiv5d2$14o4p$3@dont-email.me>
<uiv5u6$14umb$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 07:07:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1210092"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VN/VYQj5AkzQSAFgh1RxKR6Idw+ojlJU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:/lBAiEDYSzMex3j9dOsd/6pGbHc=
Content-Language: en-US
In-Reply-To: <uiv5u6$14umb$1@raubtier-asyl.eternal-september.org>
 by: Chris M. Thomasson - Tue, 14 Nov 2023 07:07 UTC

On 11/13/2023 11:00 PM, Bonita Montero wrote:
> Am 14.11.2023 um 07:51 schrieb Chris M. Thomasson:
>
>> If you say so. I have not had enough time to study up on your code.
>> Btw, are you finished with any bug fixes? Are you sure it might not
>> have any spinning out of control aspects to it? If I do model it, we
>> need to get to a concrete version of it, you say this is it, I say
>> okay, call it BonitaMonitorVersion1. Fair enough?
>
> I've got a class thead_queue which I used for years. I changed it to
> use my monitor instead a mutex plus condition variable. And the thead
> _queue is used a lot and the code that used it works as before. That's
> so much randomized synchronization for that that I for sure don't need
> any Ralacy or whatever.
>

Just get a concrete version of your Monitor, say done. Think... Think
again... No bug fixes allowed, unless Relacy finds one. Could be a very
subtle memory order issue that you might of missed...

Re: A Java- / .NET-like monitor

<uiv6e4$14tnc$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 23:08:52 -0800
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <uiv6e4$14tnc$3@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<uigp4n$1onpc$1@raubtier-asyl.eternal-september.org>
<20231108152102.495@kylheku.com>
<uihnei$21tq7$1@raubtier-asyl.eternal-september.org>
<uihnkd$21rae$1@dont-email.me>
<uihnnm$21tq7$5@raubtier-asyl.eternal-september.org>
<uihnup$21rab$4@dont-email.me>
<uihpgl$227kv$1@raubtier-asyl.eternal-september.org>
<nuT3N.20309$wvv7.18517@fx14.iad>
<uipl56$3sugf$1@raubtier-asyl.eternal-september.org>
<20231111205536.387@kylheku.com>
<uiq7o0$1thb$1@raubtier-asyl.eternal-september.org>
<20231112091106.817@kylheku.com>
<uisfvu$gsmo$1@raubtier-asyl.eternal-september.org>
<uisgpc$h32u$1@raubtier-asyl.eternal-september.org>
<uiu26e$sper$1@dont-email.me>
<uiv020$148s1$1@raubtier-asyl.eternal-september.org>
<uiv050$1462e$1@dont-email.me>
<uiv50o$14quu$1@raubtier-asyl.eternal-september.org>
<uiv5d2$14o4p$3@dont-email.me>
<uiv5u6$14umb$1@raubtier-asyl.eternal-september.org>
<uiv6b6$150ur$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 07:08:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1210092"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DgCkwijoVrWFz1IqOzeKbJ54O1TMwzfg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:0rb+LCBUwRiqqTOW29ZUtNVZS0M=
Content-Language: en-US
In-Reply-To: <uiv6b6$150ur$1@raubtier-asyl.eternal-september.org>
 by: Chris M. Thomasson - Tue, 14 Nov 2023 07:08 UTC

On 11/13/2023 11:07 PM, Bonita Montero wrote:
> Am 14.11.2023 um 08:00 schrieb Bonita Montero:
>> Am 14.11.2023 um 07:51 schrieb Chris M. Thomasson:
>>
>>> If you say so. I have not had enough time to study up on your code.
>>> Btw, are you finished with any bug fixes? Are you sure it might not
>>> have any spinning out of control aspects to it? If I do model it, we
>>> need to get to a concrete version of it, you say this is it, I say
>>> okay, call it BonitaMonitorVersion1. Fair enough?
>>
>> I've got a class thead_queue ...
>
> This is my thread_queue in the version where I didn't use my monitor:
[...]
> Concepts rock !

I had your monitor on the mind...

Re: A Java- / .NET-like monitor

<uiv6m3$1528s$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: A Java- / .NET-like monitor
Date: Mon, 13 Nov 2023 23:13:07 -0800
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <uiv6m3$1528s$1@dont-email.me>
References: <uig7jl$1l4v0$1@raubtier-asyl.eternal-september.org>
<uinloo$3d813$1@raubtier-asyl.eternal-september.org>
<uio76q$3gj34$1@raubtier-asyl.eternal-september.org>
<uiolf0$3j4r2$3@dont-email.me>
<uipl0g$3su3r$1@raubtier-asyl.eternal-september.org>
<uirdja$7lqi$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Nov 2023 07:13:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b2b7e169255d8eb4f38ce399d6fe008";
logging-data="1214748"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+umJ5E3co06Q7H272SbiccnO/2hNwRamQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:X2RWUTONqBlS8lsBxKfAIAcA96A=
Content-Language: en-US
In-Reply-To: <uirdja$7lqi$1@dont-email.me>
 by: Chris M. Thomasson - Tue, 14 Nov 2023 07:13 UTC

On 11/12/2023 12:46 PM, Chris M. Thomasson wrote:
> On 11/11/2023 8:40 PM, Bonita Montero wrote:
>> Am 11.11.2023 um 20:42 schrieb Chris M. Thomasson:
>>
>>> Is that yet another bug correction? Remember my advise, get it
>>> working then try to make it faster.
>>
>> The code immediately crashed because of an exception;
>> easiest debugging.
>>
>
> Yet, you missed it? Actually, I am not quite sure how to parse your
> response. I have not had the free time to port your code over to a
> Relacy test unit, yet...
>
> :^)

Get it to a point where you can say, no more corrections are needed, for
SURE! Then shine it one me you crazy diamond:

https://youtu.be/54W8kktFE_o?t=524

;^)


devel / comp.lang.c++ / Re: A Java- / .NET-like monitor

Pages:1234567891011
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor