<s>
In	O
computer	B-General_Concept
architecture	I-General_Concept
,	O
cache	B-General_Concept
coherence	I-General_Concept
is	O
the	O
uniformity	O
of	O
shared	O
resource	O
data	O
that	O
ends	O
up	O
stored	O
in	O
multiple	O
local	B-General_Concept
caches	I-General_Concept
.	O
</s>
<s>
When	O
clients	O
in	O
a	O
system	O
maintain	O
caches	B-General_Concept
of	O
a	O
common	O
memory	O
resource	O
,	O
problems	O
may	O
arise	O
with	O
incoherent	O
data	O
,	O
which	O
is	O
particularly	O
the	O
case	O
with	O
CPUs	B-General_Concept
in	O
a	O
multiprocessing	B-Operating_System
system	O
.	O
</s>
<s>
Suppose	O
the	O
client	O
on	O
the	O
bottom	O
updates/changes	O
that	O
memory	O
block	O
,	O
the	O
client	O
on	O
the	O
top	O
could	O
be	O
left	O
with	O
an	O
invalid	O
cache	B-General_Concept
of	O
memory	O
without	O
any	O
notification	O
of	O
the	O
change	O
.	O
</s>
<s>
Cache	B-General_Concept
coherence	I-General_Concept
is	O
intended	O
to	O
manage	O
such	O
conflicts	O
by	O
maintaining	O
a	O
coherent	O
view	O
of	O
the	O
data	O
values	O
in	O
multiple	O
caches	B-General_Concept
.	O
</s>
<s>
In	O
a	O
shared	B-Operating_System
memory	I-Operating_System
multiprocessor	B-Operating_System
system	O
with	O
a	O
separate	O
cache	B-General_Concept
memory	I-General_Concept
for	O
each	O
processor	O
,	O
it	O
is	O
possible	O
to	O
have	O
many	O
copies	O
of	O
shared	B-Operating_System
data	I-Operating_System
:	O
one	O
copy	O
in	O
the	O
main	O
memory	O
and	O
one	O
in	O
the	O
local	O
cache	B-General_Concept
of	O
each	O
processor	O
that	O
requested	O
it	O
.	O
</s>
<s>
Cache	B-General_Concept
coherence	I-General_Concept
is	O
the	O
discipline	O
which	O
ensures	O
that	O
the	O
changes	O
in	O
the	O
values	O
of	O
shared	O
operands	O
(	O
data	O
)	O
are	O
propagated	O
throughout	O
the	O
system	O
in	O
a	O
timely	O
fashion	O
.	O
</s>
<s>
The	O
following	O
are	O
the	O
requirements	O
for	O
cache	B-General_Concept
coherence	I-General_Concept
:	O
</s>
<s>
Write	O
Propagation	O
Changes	O
to	O
the	O
data	O
in	O
any	O
cache	B-General_Concept
must	O
be	O
propagated	O
to	O
other	O
copies	O
(	O
of	O
that	O
cache	B-General_Concept
line	O
)	O
in	O
the	O
peer	O
caches	B-General_Concept
.	O
</s>
<s>
Theoretically	O
,	O
coherence	O
can	O
be	O
performed	O
at	O
the	O
load/store	O
granularity	B-Operating_System
.	O
</s>
<s>
However	O
,	O
in	O
practice	O
it	O
is	O
generally	O
performed	O
at	O
the	O
granularity	B-Operating_System
of	O
cache	B-General_Concept
blocks	I-General_Concept
.	O
</s>
<s>
One	O
type	O
of	O
data	O
occurring	O
simultaneously	O
in	O
different	O
cache	B-General_Concept
memory	I-General_Concept
is	O
called	O
cache	B-General_Concept
coherence	I-General_Concept
,	O
or	O
in	O
some	O
systems	O
,	O
global	O
memory	O
.	O
</s>
<s>
In	O
a	O
multiprocessor	B-Operating_System
system	O
,	O
consider	O
that	O
more	O
than	O
one	O
processor	O
has	O
cached	O
a	O
copy	O
of	O
the	O
memory	O
location	O
X	O
.	O
</s>
<s>
The	O
following	O
conditions	O
are	O
necessary	O
to	O
achieve	O
cache	B-General_Concept
coherence	I-General_Concept
:	O
</s>
<s>
Propagating	O
the	O
writes	O
to	O
the	O
shared	B-Operating_System
memory	I-Operating_System
location	O
ensures	O
that	O
all	O
the	O
caches	B-General_Concept
have	O
a	O
coherent	O
view	O
of	O
the	O
memory	O
.	O
</s>
<s>
The	O
above	O
conditions	O
satisfy	O
the	O
Write	O
Propagation	O
criteria	O
required	O
for	O
cache	B-General_Concept
coherence	I-General_Concept
.	O
</s>
<s>
A	O
multi-processor	B-Operating_System
system	O
consists	O
of	O
four	O
processors	O
-	O
P1	O
,	O
P2	O
,	O
P3	O
and	O
P4	O
,	O
all	O
containing	O
cached	O
copies	O
of	O
a	O
shared	O
variable	O
S	O
whose	O
initial	O
value	O
is	O
0	O
.	O
</s>
<s>
Therefore	O
,	O
in	O
order	O
to	O
satisfy	O
Transaction	O
Serialization	O
,	O
and	O
hence	O
achieve	O
Cache	B-General_Concept
Coherence	I-General_Concept
,	O
the	O
following	O
condition	O
along	O
with	O
the	O
previous	O
two	O
mentioned	O
in	O
this	O
section	O
must	O
be	O
met	O
:	O
</s>
<s>
The	O
alternative	O
definition	O
of	O
a	O
coherent	O
system	O
is	O
via	O
the	O
definition	O
of	O
sequential	B-General_Concept
consistency	I-General_Concept
memory	O
model	O
:	O
"	O
the	O
cache	B-General_Concept
coherent	I-General_Concept
system	I-General_Concept
must	O
appear	O
to	O
execute	O
all	O
threads’	O
loads	O
and	O
stores	O
to	O
a	O
single	O
memory	O
location	O
in	O
a	O
total	O
order	O
that	O
respects	O
the	O
program	O
order	O
of	O
each	O
thread	O
"	O
.	O
</s>
<s>
Thus	O
,	O
the	O
only	O
difference	O
between	O
the	O
cache	B-General_Concept
coherent	I-General_Concept
system	I-General_Concept
and	O
sequentially	B-General_Concept
consistent	I-General_Concept
system	O
is	O
in	O
the	O
number	O
of	O
address	O
locations	O
the	O
definition	O
talks	O
about	O
(	O
single	O
memory	O
location	O
for	O
a	O
cache	B-General_Concept
coherent	I-General_Concept
system	I-General_Concept
,	O
and	O
all	O
memory	O
locations	O
for	O
a	O
sequentially	B-General_Concept
consistent	I-General_Concept
system	O
)	O
.	O
</s>
<s>
Another	O
definition	O
is	O
:	O
"	O
a	O
multiprocessor	B-Operating_System
is	O
cache	B-General_Concept
consistent	O
if	O
all	O
writes	O
to	O
the	O
same	O
memory	O
location	O
are	O
performed	O
in	O
some	O
sequential	O
order	O
"	O
.	O
</s>
<s>
Rarely	O
,	O
but	O
especially	O
in	O
algorithms	O
,	O
coherence	O
can	O
instead	O
refer	O
to	O
the	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
.	O
</s>
<s>
Multiple	O
copies	O
of	O
same	O
data	O
can	O
exist	O
in	O
different	O
cache	B-General_Concept
simultaneously	O
and	O
if	O
processors	O
are	O
allowed	O
to	O
update	O
their	O
own	O
copies	O
freely	O
,	O
an	O
inconsistent	O
view	O
of	O
memory	O
can	O
result	O
.	O
</s>
<s>
The	O
two	O
most	O
common	O
mechanisms	O
of	O
ensuring	O
coherency	O
are	O
snooping	B-General_Concept
and	O
directory-based	B-Architecture
,	O
each	O
having	O
their	O
own	O
benefits	O
and	O
drawbacks	O
.	O
</s>
<s>
Snooping	B-General_Concept
based	O
protocols	O
tend	O
to	O
be	O
faster	O
,	O
if	O
enough	O
bandwidth	B-General_Concept
is	O
available	O
,	O
since	O
all	O
transactions	O
are	O
a	O
request/response	O
seen	O
by	O
all	O
processors	O
.	O
</s>
<s>
The	O
drawback	O
is	O
that	O
snooping	B-General_Concept
is	O
n't	O
scalable	O
.	O
</s>
<s>
Every	O
request	O
must	O
be	O
broadcast	O
to	O
all	O
nodes	O
in	O
a	O
system	O
,	O
meaning	O
that	O
as	O
the	O
system	O
gets	O
larger	O
,	O
the	O
size	O
of	O
the	O
(	O
logical	O
or	O
physical	O
)	O
bus	O
and	O
the	O
bandwidth	B-General_Concept
it	O
provides	O
must	O
grow	O
.	O
</s>
<s>
Directories	O
,	O
on	O
the	O
other	O
hand	O
,	O
tend	O
to	O
have	O
longer	O
latencies	O
(	O
with	O
a	O
3	O
hop	O
request/forward/respond	O
)	O
but	O
use	O
much	O
less	O
bandwidth	B-General_Concept
since	O
messages	O
are	O
point	O
to	O
point	O
and	O
not	O
broadcast	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
many	O
of	O
the	O
larger	O
systems	O
(	O
>64	O
processors	O
)	O
use	O
this	O
type	O
of	O
cache	B-General_Concept
coherence	I-General_Concept
.	O
</s>
<s>
First	O
introduced	O
in	O
1983	O
,	O
snooping	B-General_Concept
is	O
a	O
process	O
where	O
the	O
individual	O
caches	B-General_Concept
monitor	O
address	O
lines	O
for	O
accesses	O
to	O
memory	O
locations	O
that	O
they	O
have	O
cached	O
.	O
</s>
<s>
For	O
the	O
snooping	B-General_Concept
mechanism	O
,	O
a	O
snoop	B-General_Concept
filter	I-General_Concept
reduces	O
the	O
snooping	B-General_Concept
traffic	O
by	O
maintaining	O
a	O
plurality	O
of	O
entries	O
,	O
each	O
representing	O
a	O
cache	B-General_Concept
line	O
that	O
may	O
be	O
owned	O
by	O
one	O
or	O
more	O
nodes	O
.	O
</s>
<s>
When	O
replacement	O
of	O
one	O
of	O
the	O
entries	O
is	O
required	O
,	O
the	O
snoop	B-General_Concept
filter	I-General_Concept
selects	O
for	O
the	O
replacement	O
of	O
the	O
entry	O
representing	O
the	O
cache	B-General_Concept
line	O
or	O
lines	O
owned	O
by	O
the	O
fewest	O
nodes	O
,	O
as	O
determined	O
from	O
a	O
presence	O
vector	O
in	O
each	O
of	O
the	O
entries	O
.	O
</s>
<s>
A	O
temporal	O
or	O
other	O
type	O
of	O
algorithm	O
is	O
used	O
to	O
refine	O
the	O
selection	O
if	O
more	O
than	O
one	O
cache	B-General_Concept
line	O
is	O
owned	O
by	O
the	O
fewest	O
nodes	O
.	O
</s>
<s>
In	O
a	O
directory-based	B-Architecture
system	O
,	O
the	O
data	O
being	O
shared	O
is	O
placed	O
in	O
a	O
common	O
directory	O
that	O
maintains	O
the	O
coherence	O
between	O
caches	B-General_Concept
.	O
</s>
<s>
The	O
directory	O
acts	O
as	O
a	O
filter	O
through	O
which	O
the	O
processor	O
must	O
ask	O
permission	O
to	O
load	O
an	O
entry	O
from	O
the	O
primary	O
memory	O
to	O
its	O
cache	B-General_Concept
.	O
</s>
<s>
When	O
an	O
entry	O
is	O
changed	O
,	O
the	O
directory	O
either	O
updates	O
or	O
invalidates	O
the	O
other	O
caches	B-General_Concept
with	O
that	O
entry	O
.	O
</s>
<s>
Distributed	B-Operating_System
shared	I-Operating_System
memory	I-Operating_System
systems	O
mimic	O
these	O
mechanisms	O
in	O
an	O
attempt	O
to	O
maintain	O
consistency	O
between	O
blocks	O
of	O
memory	O
in	O
loosely	O
coupled	O
systems	O
.	O
</s>
<s>
Coherence	B-General_Concept
protocols	I-General_Concept
apply	O
cache	B-General_Concept
coherence	I-General_Concept
in	O
multiprocessor	B-Operating_System
systems	O
.	O
</s>
<s>
The	O
intention	O
is	O
that	O
two	O
clients	O
must	O
never	O
see	O
different	O
values	O
for	O
the	O
same	O
shared	B-Operating_System
data	I-Operating_System
.	O
</s>
<s>
Protocols	O
can	O
also	O
be	O
classified	O
as	O
snoopy	O
or	O
directory-based	B-Architecture
.	O
</s>
<s>
Typically	O
,	O
early	O
systems	O
used	O
directory-based	B-Architecture
protocols	O
where	O
a	O
directory	O
would	O
keep	O
a	O
track	O
of	O
the	O
data	O
being	O
shared	O
and	O
the	O
sharers	O
.	O
</s>
<s>
Write-invalidate	O
When	O
a	O
write	O
operation	O
is	O
observed	O
to	O
a	O
location	O
that	O
a	O
cache	B-General_Concept
has	O
a	O
copy	O
of	O
,	O
the	O
cache	B-General_Concept
controller	O
invalidates	O
its	O
own	O
copy	O
of	O
the	O
snooped	O
memory	O
location	O
,	O
which	O
forces	O
a	O
read	O
from	O
main	O
memory	O
of	O
the	O
new	O
value	O
on	O
its	O
next	O
access	O
.	O
</s>
<s>
Write-update	O
When	O
a	O
write	O
operation	O
is	O
observed	O
to	O
a	O
location	O
that	O
a	O
cache	B-General_Concept
has	O
a	O
copy	O
of	O
,	O
the	O
cache	B-General_Concept
controller	O
updates	O
its	O
own	O
copy	O
of	O
the	O
snooped	O
memory	O
location	O
with	O
the	O
new	O
data	O
.	O
</s>
<s>
If	O
the	O
protocol	O
design	O
states	O
that	O
whenever	O
any	O
copy	O
of	O
the	O
shared	B-Operating_System
data	I-Operating_System
is	O
changed	O
,	O
all	O
the	O
other	O
copies	O
must	O
be	O
"	O
updated	O
"	O
to	O
reflect	O
the	O
change	O
,	O
then	O
it	O
is	O
a	O
write-update	O
protocol	O
.	O
</s>
<s>
Various	O
models	O
and	O
protocols	O
have	O
been	O
devised	O
for	O
maintaining	O
coherence	O
,	O
such	O
as	O
MSI	B-General_Concept
,	O
MESI	B-General_Concept
(	O
aka	O
Illinois	O
)	O
,	O
MOSI	B-General_Concept
,	O
MOESI	B-General_Concept
,	O
MERSI	B-General_Concept
,	O
MESIF	B-General_Concept
,	O
write-once	B-General_Concept
,	O
Synapse	O
,	O
Berkeley	O
,	O
Firefly	B-Device
and	O
Dragon	B-General_Concept
protocol	I-General_Concept
.	O
</s>
<s>
In	O
2011	O
,	O
ARM	O
Ltd	O
proposed	O
the	O
AMBA	O
4	O
ACE	O
for	O
handling	O
coherency	O
in	O
SoCs	B-Architecture
.	O
</s>
