Article View: rec.arts.sf.written
Article #689Re: โThe end of software secrecy is almost upon
From: Chris M. Thomasson
Date: Mon, 26 Oct 2026 20:12
Date: Mon, 26 Oct 2026 20:12
241 lines
7877 bytes
7877 bytes
On 10/26/2026 12:45 PM, Michael S wrote:
> On Mon, 26 Oct 2026 16:16:46 -0000 (UTC)
> boltar@caprica.universe wrote:
>
>> On Mon, 26 Oct 2026 14:41:54 GMT
>> scott@slp53.sl.home (Scott Lurndal) gabbled:
>>> boltar@caprica.universe writes:
>>>> C++ threading didn't have 3 level locking until 2017 making it
>>>> effectively useless IMO. Perhaps that was down to the lowest common
>>>> denominator called Windows.
>>>>
>>>
>>> Mind defining your terminology? "3 level locking", in particular?
>>
>> If you have to ask....
>>
>> 1. No lock
>> 2. Write lock - Read only access, writer blocked until all readers
>> out of critic al section)
>> 3. Read-write lock - all threads other than the one in section block)
>>
>
> Windows got Slim Reader/Writer Locks in Vista (2006-11) at the same
> time as conditional variables. 5 years before C++11.
> https://learn.microsoft.com/en-us/windows/win32/sync/slim-reader-writer--srw--locks
> Of course WinXP remained popular for few more years, approximately up
> until 2nd half of 2010, but that too predates publication of C++11 in
> 2011-09.
>
>> This is basic stuff FFS. C++ finally got around to #2 with
>> shared_mutex in 2017 and its rather critical for certain algorithms.
>>
>>> Assigning a canonical "lock number" to each lock, and failing a lock
>>> request for a lock with a lower number than that already held is
>>> a design pattern that has been around since 1980 (in Burroughs
>>> mainframes it was implemented in hardware). Easy enough to do
>>> prior to C++17 in software.
>>
>> Thats something else entirely.
>>
>>> And your assertion that a language that doesn't support it
>>> intrinsically is "useless" is ridiculous.
>>
>> Not useless then, just less useful.
>>
>
> I never ever used what you call "3 level locking", not even by mistake.
> But then, I don't write complicated apps on "big" computers day in day
> out.
Still don't really know what he means by 3 level locking. Using lock
hashing where an address is hashed into a lock index such that no object
needs its own lock is nothing new. But it needs to be sorted and deduped.
(google groups wrt usenet seems to be back up now)
https://groups.google.com/g/comp.lang.c++/c/sV4WC_cBb9Q/m/SkSqpSxGCAAJ
some of my old relacy code:
#include <relacy/relacy.hpp>
#include <cstdio>
#include <cstddef>
#include <cstdlib>
#include <string>
#include <vector>
#if ! defined (NDEBUG)
# define CT_DBG_PRINTF(e) std::printf e
#else
# define CT_DBG_PRINTF(e) ((void)0)
#endif
#define CT_THREADS (5)
#define CT_MUTEX_TABLE_N (64)
struct ct_mutex_table
{
rl::mutex m_mutexs[CT_MUTEX_TABLE_N];
std::size_t
hash_ptr(
void* p
) const {
return rl::hash_ptr(p, CT_MUTEX_TABLE_N);
}
};
struct ct_thread_mutex_hash
{
std::vector<std::size_t> m_hashed_idxs;
// must be before any locks!
void finalize()
{
std::sort(
m_hashed_idxs.begin(),
m_hashed_idxs.end());
m_hashed_idxs.erase(
std::unique(
m_hashed_idxs.begin(),
m_hashed_idxs.end()),
m_hashed_idxs.end());
}
// BEFORE WE CALL, WE NEED TO sort and dedup before this.
void
lock(
ct_mutex_table& mutex_table
) {
for (auto& mtx_idx : m_hashed_idxs)
{
rl::mutex& mtx = mutex_table.m_mutexs[mtx_idx];
mtx.lock($);
}
}
// does not really even need to be reversed...
void
unlock(
ct_mutex_table& mutex_table
) {
for (auto& mtx_idx : m_hashed_idxs)
{
rl::mutex& mtx = mutex_table.m_mutexs[mtx_idx];
mtx.unlock($);
}
}
};
struct ct_state
{
ct_mutex_table m_mutex_table;
VAR_T(int) m_var_0 = 0;
VAR_T(int) m_var_1 = 1;
VAR_T(int) m_var_2 = 2;
void worker_thread_a()
{
ct_thread_mutex_hash self_hash;
self_hash.m_hashed_idxs.push_back(
m_mutex_table.hash_ptr(&m_var_0));
self_hash.m_hashed_idxs.push_back(
m_mutex_table.hash_ptr(&m_var_1));
self_hash.finalize();
self_hash.lock(m_mutex_table);
VAR(m_var_0) = 42;
VAR(m_var_1) = 128;
self_hash.unlock(m_mutex_table);
}
void worker_thread_b()
{
ct_thread_mutex_hash self_hash;
// Seed!
{
self_hash.m_hashed_idxs.push_back(
m_mutex_table.hash_ptr(&m_var_1));
self_hash.m_hashed_idxs.push_back(
m_mutex_table.hash_ptr(&m_var_0));
}
// Okay... Finalize it...
{
self_hash.finalize();
}
// Finally, we can lock the bastard!
{
self_hash.lock(m_mutex_table);
{
VAR(m_var_0) = 99;
VAR(m_var_1) = 77;
}
self_hash.unlock(m_mutex_table);
}
}
};
struct ct_multex_relacy_test_v000
: rl::test_suite<ct_multex_relacy_test_v000, CT_THREADS>
{
ct_state m_state = { };
void before()
{
// not sure to init m_state here. Is it already init?
}
void
thread(
unsigned tidx
) {
if (tidx == 0)
m_state.worker_thread_a();
else
m_state.worker_thread_b();
}
};
int main(int argc, char** argv)
{
{
rl::test_params p;
p.iteration_count = argc > 1 ? (unsigned)atoi(argv[1]) : 100000;
p.execution_depth_limit = 100000;
if (argc > 2) {
std::string m = argv[2];
if (m == "full") p.search_type = rl::sched_full;
else if (m == "bound") { p.search_type = rl::sched_bound;
p.context_bound = argc > 3 ? atoi(argv[3]) : 2; }
}
rl::simulate<ct_multex_relacy_test_v000>(p);
}
return 0;
}
Technical Details
Message-ID:
<11boc79$u4nn$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11amvre$15far$1@dont-email.me> <11bj08r$309uk$1@dont-email.me> <11bj7na$5bt$1@reader2.panix.com> <20261025011151.000038ef@yahoo.com> <11bjif3$7p0$1@reader2.panix.com> <11bkfcc$104cc$1@dont-email.me> <20261025225619.000074a5@yahoo.com> <11bn89f$2s5ol$1@dont-email.me> <SEJDS.60663$GS_e.59175@fx21.iad> <11bnude$2sv8n$1@dont-email.me> <20261026214517.00005217@yahoo.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> Newsgroups: rec.arts.sf.written,comp.lang.fortran,comp.lang.c++,alt.comp.lang.rust,alt.folklore.computers Subject: Re: โThe end of software secrecy is almost upon Date: Mon, 26 Oct 2026 13:12:24 -0700 Organization: A noiseless patient Spider Lines: 241 Message-ID: <11boc79$u4nn$1@dont-email.me> References: <11amvre$15far$1@dont-email.me> <11bj08r$309uk$1@dont-email.me> <11bj7na$5bt$1@reader2.panix.com> <20261025011151.000038ef@yahoo.com> <11bjif3$7p0$1@reader2.panix.com> <11bkfcc$104cc$1@dont-email.me> <20261025225619.000074a5@yahoo.com> <11bn89f$2s5ol$1@dont-email.me> <SEJDS.60663$GS_e.59175@fx21.iad> <11bnude$2sv8n$1@dont-email.me> <20261026214517.00005217@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 26 Oct 2026 20:12:26 +0000 (UTC) Injection-Info: dont-email.me; logging-data="987895"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gmN1jfir/WqpdMCbztAfZnqxcW4UUJ/w="; posting-host="49da529de1e605d0c2cf1bd5b7b86f4a" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:gZ8yCl+3fT0T32X0oBwDonKljAo= sha256:FYPC5KV839E4d+gFK00INLMJ1TI/sKfA9qgIgiRZH9c= sha1:8p165d5ui1VnQLU5fFrK0vkL9dU= sha256:fQA999tyu0PCoLTY7+0MmSZVj/oIdeNYkYsGcwVfhP0= In-Reply-To: <20261026214517.00005217@yahoo.com> Content-Language: en-US