So here I'm showing you a set of accesses, memory accesses down on processor P1
read access, and write access and so on,
and these are the memory location being touched
by these accesses on P1. And on P2 I'm showing some real set of accesses to
shared memory locations, and we know that Processor
P1 accessing memory and processor P2 accessing memory,
are completely independent of one another And therefore it is possible that
in one execution of P1 and P2 this particular
access of of writing it to memory location
A Happens after reading a memory location, a happens
on P1 in one execution. And if you run the same program again,
P2 and P1 constituting the program run it again. It's possible that
another execution of the same program the write of a happens before the
read of a. It's perfectly feasible for this to happen because there
is no guarantee on the ordering of these axises going to main memory.
And if you think about it, both of
these executions, whether it is earlier execution where write
happened after this read, or this execution in
which the write is happening before the read. Both
these executions are reasonable and correct and something that the programmer
can live with. It's acceptable to the programmer. Now in other
words, what the programmer needs to know is what to expect from
the system in terms of the behaviour of shared memory reads and writes that
can be emanating from several different processors.
And this is what is called the memory
consistency model. So the expectation of the
programmer is, is, is what is engrained
in this memory consistency model. As a
programmer, you don't want any surprises. And there's
a purpose of the memory consistency model to
sort of satisfy the expectation of the programmer.
So I'm going to talk to you about one
particular memory consistency model, which is called a sequential
consistency memory model. And you consider the axises
from P1 and P2. Well. One expectation that you
have of the programmer is that the accesses
that you have on a particular processor, is going
to be exactly in the order in which your radiant
or in other words, if you look at these sequences
of accesses, you have the right of b here and
the need of b here. You know that your one expect
to see when you do this V, whatever you wrote
here is what you expect to see. That's what's called
a program order. What you expect is the program order
to be maintained, namely the order in which you've generated memory
axises should be maintained by the execution on
that processor. That's program order. And in addition to
that, there is this interleaving of memory accesses between
P1 and P2. And this is where we said,
we have no way of controlling the, the
order in which these accesses are going to be
satisfied by the memory. Because it depends on the
execution of P1 on processor P1. And the execution
on P2 and how that each memory and so on. And so this interleving can be
arbatrary. That is, interleaving between axises that you
see here and the axises that you see here
can be arbitrary. So, that's the sequencal consistency
memory model, which has two parts to it.
One is the program order. That is the
order that you see, textually, in every individual processes.
I' m showing you two here, but you can have
any of these processes. But in each one of these
processes, the textual order in which memory axises are generated,
they're going to be satisfied. That's the program order. On the
other hand, the interleaving of these memory access has occurred
all of the processes is going to be obituary. So
those are the two properties of the sequential memory consistency
model. In order an analogy that will drive home the
point about the sequential consistency and what you
might see In a casino and if you,
if you watch a, a casino card shark shuffle cards. He might take a card deck
and split it into two halves, and then he'll do a merge shuffle of two splits,
and, and, and create a complete deck. Exactly
what's going on with sequential consistency. You have
Splits of memory axis's on serveral
different processors, and they're getting interlinked in
some fashion. Just like card shuffler is
interweaving the cards from two decks and
creating one card deck. All of it.
By the way, this particular memory consistency
model's sequential consistency Was proposed by Leslie
Lamport and, this is a popular guy.
You're going to see him again later on when
we talk about distributor systems. But he came
up with this idea of sequential consisting memory
model back in 1977. And since then there have
been a lot of different consistency models that
have been proposed. And in future lessons on
distributed systems, we will see other forms of
memory consistency models such as release consistency and lazy
release consistency and eventual consistency. But hold on.
We will come back to that later. on.