Is concurrency hard?
Joe Armstrong (AL/EAB)
Wed Nov 2 10:13:14 CET 2005
> -----Original Message-----
> From: owner-erlang-questions@REDACTED
> [mailto:owner-erlang-questions@REDACTED]On Behalf Of Lyn Headley
> Sent: den 2 november 2005 02:26
> To: erlang-questions@REDACTED
> Subject: RE: Is concurrency hard?
> > We are used to handling data where everybody has their own private
> > copy of a data structure.
> > If I say "think of the number 2007" - then I send a sound message
> > to my listeners - each one
> > of them who hears the message forms their own private mental image
> > of "2007" - there is no shared
> > data structure.
> I'm not sure about this. In fact I think we are constantly working
> on both a sequential and concurrent level with both shared data
> structures and parallelism. Take an academic lecture. We are all in
> the same room and more importantly share the same atmosphere which
> transmits our messages. Only one of us can use this atmosphere at a
> time and we have to negotiate access to it by raising our hands and
> having a scheduled speaker. Furthermore there is a shared sense that
> what is going on is a lecture. coughs and throat clearing are
> defined as peripheral.
I don't think so - N people are receiving more or less the same sensory data.
If you asked them afterwards what had happened (in detail) they would all disagree
that's because they receive slightly different sensory inputs.
Now you can do an experiment to test this.
Arrange that two people at the left and right side of your lecture theatre suddenly
explode and vanish in a puff of orange smoke with a very lound bang.
Make sure that they have synchronised watches, and that they vanish
at the "same" time (ie the accuracy of the watches was greater than the time taken for a ray
of light to pass from one side of the lecture theatre to the other).
Now ask the question: Who vanished first?
Now the people on the left hand side of the theatre would say that the person at the left had side had vanished first - and the people on the right hand side would say that the person at the right had vanished first.
On dear - who is right? - both - it is the question that is silly - you cannot ask questions about
the simultaneity of event occurring at different places (basic physics).
> But maybe that was actually your point. The only thing that is
> shared is the channel. I suppose that's not a data structure. But
> it's a resource. Is that right?
That's not how I'd put it.
I'm a physicist (or at least I was - a long time ago)
Now in physics there is no concept of sharing and no concept of simultaneity at
a distance. We can only say that two things occur at the same time if they occur at the same place.
In physics, light propagates through a media (called the ether) - but nobody
knows what the ether is. In Newtonian and relativistic mechanics there is no sharing of the
ether - everybody could use it at once. << In esoteric things like Brane universes and 4 + 22 dimensional universes there are some twisting parameters, so perhaps, photons might get a
"time slice" move a bit and then get swapped out while the other universes and dimensions
do their bit - who knows>>
So to me channels don't really exists - there are just labels attached to messages.
If we say "A talks to B" (in a room) then A doesn't *really* talk to B - there is no A to B channel.
A talks - everybody in the room could potentially listen - but the message was intended for B.
So we might call this a channel - just for convenience.
In the real world (the physical world) there is no sharing, there are no channels, no locks
no simultaneous things happening in different places (well there are but we can only indirectly
infer this *after* the even) - all there are are messages containing information.
Since this is the case in the real world then software that pretends that this is not the case
is bound to run into problems.
How can we ensure that two computers in different places have the same data? - we can't -
this is the well known Byzantine Generals problem. We can only be reasonable sure - normally reasonable
means "two phase commit" has succeeded - but we're really deluding ourselves. All we can say
with certainty is "the last message I received from this machine had this content"
At first it seems difficult to program things where each process has it's own view of the
world and this view is only changed when the process receives a message - but after a while
this becomes second nature. This is how we work - ie how we (people) interact - we receive messages
through our senses - we send messages - that's it (Unless you want to introduce a deity)
> Lyn Headley
> UCSD Communication and Science Studies
> Yahoo! Mail - PC Magazine Editors' Choice 2005
More information about the erlang-questions