<s>
Double	B-Operating_System
compare-and-swap	I-Operating_System
(	O
DCAS	O
or	O
CAS2	O
)	O
is	O
an	O
atomic	B-General_Concept
primitive	I-General_Concept
proposed	O
to	O
support	O
certain	O
concurrent	B-Architecture
programming	I-Architecture
techniques	O
.	O
</s>
<s>
DCAS	O
takes	O
two	O
not	O
necessarily	O
contiguous	O
memory	O
locations	O
and	O
writes	O
new	O
values	O
into	O
them	O
only	O
if	O
they	O
match	O
pre-supplied	O
"	O
expected	O
"	O
values	O
;	O
as	O
such	O
,	O
it	O
is	O
an	O
extension	O
of	O
the	O
much	O
more	O
popular	O
compare-and-swap	B-Operating_System
(	O
CAS	O
)	O
operation	O
.	O
</s>
<s>
DCAS	O
is	O
sometimes	O
confused	O
with	O
the	O
double-width	O
compare-and-swap	B-Operating_System
(	O
DWCAS	O
)	O
implemented	O
by	O
instructions	O
such	O
as	O
x86	O
CMPXCHG16B	O
.	O
</s>
<s>
In	O
his	O
doctoral	O
thesis	O
,	O
Michael	O
Greenwald	O
recommended	O
adding	O
DCAS	O
to	O
modern	O
hardware	O
,	O
showing	O
it	O
could	O
be	O
used	O
to	O
create	O
easy-to-apply	O
yet	O
efficient	O
software	B-Operating_System
transactional	I-Operating_System
memory	I-Operating_System
(	O
STM	O
)	O
.	O
</s>
<s>
One	O
of	O
the	O
advantages	O
of	O
DCAS	O
is	O
the	O
ability	O
to	O
implement	O
atomic	O
deques	B-Application
(	O
i.e.	O
</s>
<s>
doubly	B-Data_Structure
linked	I-Data_Structure
lists	I-Data_Structure
)	O
with	O
relative	O
ease	O
.	O
</s>
<s>
In	O
general	O
however	O
,	O
DCAS	O
is	O
not	O
a	O
silver	O
bullet	O
:	O
implementing	O
lock-free	B-Operating_System
and	I-Operating_System
wait-free	I-Operating_System
algorithms	I-Operating_System
using	O
it	O
is	O
typically	O
just	O
as	O
complex	O
and	O
error-prone	O
as	O
for	O
CAS	O
.	O
</s>
<s>
Motorola	O
at	O
one	O
point	O
included	O
DCAS	O
in	O
the	O
instruction	O
set	O
for	O
its	O
68k	B-Device
series	O
;	O
however	O
,	O
the	O
slowness	O
of	O
DCAS	O
relative	O
to	O
other	O
primitives	O
(	O
apparently	O
due	O
to	O
cache	O
handling	O
issues	O
)	O
led	O
to	O
its	O
avoidance	O
in	O
practical	O
contexts	O
.	O
</s>
<s>
The	O
generalization	O
of	O
DCAS	O
to	O
more	O
than	O
two	O
addresses	O
is	O
sometimes	O
called	O
MCAS	O
(	O
multi-word	O
CAS	O
)	O
;	O
MCAS	O
can	O
be	O
implemented	O
by	O
a	O
nestable	O
LL/SC	B-Operating_System
,	O
but	O
such	O
a	O
primitive	O
is	O
not	O
directly	O
available	O
in	O
hardware	O
.	O
</s>
<s>
In	O
2013	O
,	O
Trevor	O
Brown	O
,	O
Faith	O
Ellen	O
,	O
and	O
Eric	O
Ruppert	O
have	O
implemented	O
in	O
software	O
a	O
multi-address	O
LL/SC	B-Operating_System
extension	O
(	O
which	O
they	O
call	O
LLX/SCX	O
)	O
that	O
while	O
being	O
more	O
restrictive	O
than	O
MCAS	O
enabled	O
them	O
,	O
via	O
some	O
automated	O
code	O
generation	O
,	O
to	O
implement	O
one	O
of	O
the	O
best	O
performing	O
concurrent	O
binary	B-Language
search	I-Language
tree	I-Language
(	O
actually	O
a	O
chromatic	O
tree	O
)	O
,	O
slightly	O
beating	O
the	O
JDK	B-Language
CAS-based	O
skip	O
list	O
implementation	O
.	O
</s>
<s>
In	O
general	O
,	O
DCAS	O
can	O
be	O
provided	O
by	O
a	O
more	O
expressive	O
hardware	B-Operating_System
transactional	I-Operating_System
memory	I-Operating_System
.	O
</s>
<s>
IBM	O
POWER8	B-Device
and	O
Intel	O
Intel	B-Operating_System
TSX	I-Operating_System
provide	O
working	O
implementations	O
of	O
transactional	B-Operating_System
memory	I-Operating_System
.	O
</s>
<s>
Sun	O
's	O
cancelled	O
Rock	B-Device
processor	I-Device
would	O
have	O
supported	O
it	O
as	O
well	O
.	O
</s>
