Shared - Another Thread

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Oct 17 21:55:48 UTC 2018


On Wed, Oct 17, 2018 at 09:29:07PM +0000, Stefan Koch via Digitalmars-d wrote:
> On Wednesday, 17 October 2018 at 21:12:49 UTC, Stefan Koch wrote:
> > [another person] cannot actually occupy the same space. It is
> > physically impossible.
> 
> Actually, that's not quite true, If they were to try hard enough the
> result would be nuclear fusion, (I am guessing (I am not a phsysist)),
> in any case it would certainly mess up the state of everyone involved;
> which is exactly what happens win multi-threaded situations.

Nah, that's not even anywhere close to nuclear fusion.

The atoms which make up your body (and basically everything else) are
mostly empty, with just a tiny speck of a nucleus, and a bunch of
extremely tiny electrons zipping about. There's plenty of room for
hundreds, if not thousands or millions, of persons to occupy the same
space without any of the particles running into each other.

The problem, of course, is that they are also charged particles, and the
electromagnetic forces that hold the atom in place would be greatly
disturbed if two atoms were to occupy the same space simultaneously,
leading to a (very fast and very violent) reorganization of nucleii and
electrons.  What that looks like macroscopically, I can't say exactly,
but certainly delicate structures like proteins, DNA, lipid layers, and
such would cease to exist, their constituent particles being violently
scattered every which way in the course of reorganizing themselves into
new structures that would bring the electromagnetic forces back into
balance (and that, in all likelihood, won't resemble anything close to
their starting molecular structures).  Whatever the result may be, I'm
pretty certain it would not have good consequences for the biological
processes built upon said delicate structures. To say the least. :-D

Two threads trying to access the same memory location at the same time,
by comparison, would tend to have much less drastic, though no less
dire, consequences.  :-D  Program crashes and security holes aside, at
least we aren't talking about the transistors in the CPU suddenly (and
violently) rearranging themselves into an unrecognizable slag (possibly
with accompanying loud noises and flying shrapnel).  Even the program
structure would mostly remain intact, though of course, logical
consistency would be compromised, and you know what Walter says about
programs that continue bungling forwards after a false assertion -- the
code might wind up doing arbitrary things it was never intended to do,
while being perfectly convinced that it is doing exactly what it was
told.

But nobody will be building a fusion engine out of race conditions
anytime in the foreseeable future. :-D


T

-- 
All men are mortal. Socrates is mortal. Therefore all men are Socrates.


More information about the Digitalmars-d mailing list