Article View: alt.comp.lang.rust
Article #464Re: “The end of software secrecy is almost upon
From: Chris M. Thomasson
Date: Sat, 31 Oct 2026 20:14
Date: Sat, 31 Oct 2026 20:14
278 lines
8516 bytes
8516 bytes
On 10/31/2026 2:38 AM, boltar@caprica.universe wrote:
> On Fri, 30 Oct 2026 20:37:14 +0100
> Jeroen Belleman <jeroen@nospam.please> gabbled:
>> On 10/30/26 17:07, boltar@caprica.universe wrote:
>>> On Fri, 30 Oct 2026 11:25:01 -0000 (UTC)
>>> cross@spitfire.i.gajendra.net (Dan Cross) gabbled:
>>>> In article <20261030105900.000020ce@yahoo.com>,
>>>> Michael S <already5chosen@yahoo.com> wrote:
>>>>>> Only if you intended to close the TTY the programs were started
>>>>>> on. Otherwise, I don't see why it would be necessary:
>>>>>
>>>>> What happens when caller is GUI-style application?
>>>>
>>>> That depends on a number of factors, but basically, "it does the
>>>> same thing". Why would it be any different?
>>>
>>> Windows treats GUI apps entirely differently to console ones so a
>>> Windows
>>> dev might not appreciate that on unix there is no demarcation - a GUI
>>> app
>>> simply has a network connection to the X server and it can either sit in
>>> an event loop waiting for events - as per a windows main thread - or
>>> go do
>>> other things and periodically check the X event list.
>>>
>>
>> That's where threads are useful: The GUI is one thread, and the "other
>> things" are in one or more other threads. There are altogether too many
>> programs that hang the GUI while "other things" are going on. That
>> should never happen!
>
> If its multithreaded but that still happens someone probably has created
> too
> many critical sections with too many locks.
>
Makes no sense at all. Have you taken a look at my multex? It can create
a shit lod of mutexes, and never deadlock. It keeps a strict locking
order. Sorts and dedups the mutexes. Also, notice that an object does
not need its own mutex:
So, I have the most recent version and coded up my old multex algo. It
100% dead lock free and allows a thread to locks multiple objects in any
order and lock them. All of the lock ordering is taken care of in the
finalize function. Basically a thread seeds its per thread lock indices
with addresses to objects it wants to lock. Calls finalize, then locks
them. Does its thing and then unlocks them. Fwiw, here is my Relacy test
output:
struct ct_multex_relacy_test_v000
65% (65536/100000)
iterations: 100000
total time: 9390
throughput: 10649
D:\ct_dev\ct_msvc\projects\ct_relacy_test\x64\Debug\ct_relacy_test.exe
(process 13356) exited with code 0 (0x0).
Press any key to close this window . . .
Any my 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;
}
/*
#include <relacy/relacy.hpp>
#include <iostream>
int
main()
{
std::cout << "ct_relacy_test\n";
std::cout << "____________________________________________" <<
std::endl;
{
}
std::cout << "____________________________________________" <<
std::endl;
std::cout << "ct_relacy_test fin! :^)\n";
return 0;
}
*/
Technical Details
Message-ID:
<11c5i7n$1dqbi$2@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> <20261030005434.00005458@yahoo.com> <11c0v1j$her$1@reader2.panix.com> <20261030105900.000020ce@yahoo.com> <11c1uqd$keq$1@reader2.panix.com> <11c2fcl$19bk2$1@dont-email.me> <11c2rla$hko3$2@dont-email.me> <11c4cv7$39h8m$1@dont-email.me>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: Sat, 31 Oct 2026 13:14:47 -0700 Organization: A noiseless patient Spider Lines: 278 Message-ID: <11c5i7n$1dqbi$2@dont-email.me> References: <11amvre$15far$1@dont-email.me> <20261030005434.00005458@yahoo.com> <11c0v1j$her$1@reader2.panix.com> <20261030105900.000020ce@yahoo.com> <11c1uqd$keq$1@reader2.panix.com> <11c2fcl$19bk2$1@dont-email.me> <11c2rla$hko3$2@dont-email.me> <11c4cv7$39h8m$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 31 Oct 2026 20:14:48 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1501554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197lEq9YWTKx1x1P+56gUCiWo0b1OcfSWc="; posting-host="e055ed2a9bbc4c65ed13e0141dd90213" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:jbHFVYmFXBdgRlCTKTxzpFkAA/Y= sha256:msio0IFVMPvZhIXgKMtbn91nw2xfZHMP7avCq0YovZk= sha1:apuNITl0mHE/kOMcFwmbJxAEUao= sha256:ut4LF2qE2MPemp990JszgOk176aCHRAaTC5w1BT2hQc= In-Reply-To: <11c4cv7$39h8m$1@dont-email.me> Content-Language: en-US