views:

229

answers:

3

So; on a 64 bit SPARC CPU which is v9 compliant, there exists I know a cas instruction. This operates on single word length values.

I've also seen on the web reference to a casx instruction - but I can't find out anything much more about it.

I'm wondering - is this a double word compare and swap?

And if not, the general question is; IS there a double word compare and swap?

A: 

CASXA. See The SPARC Architecture Manual.

AProgrammer
CASA swaps 32 bit values. CASXA swaps 64 bit values. Sparc v9 as I understand it is a 64 bit CPU. I'm looking for a double-word CAS, e.g. 128 bits on a 64 bit CPU. I looks then like this does not exist on Sparc.
Blank Xavier
Ah... the old ambiguity of "word" in an architecture which expand.
AProgrammer
Yes - I realised when I read the manual, Sparc thinks of word as 32 bits.
Blank Xavier
A: 

Also note that casx does exist, however it's a synthetic instruction (i.e. a simplified mnemonic) for casxa. See Table 43 in the aforementioned SPARC Architecture Manual:

Synthetic:   casx [regrs1], regrs2, regrd 
Instruction: casxa [regrs1]#ASI_P, regrs2, regrd 
Description: compare and swap extended
Dave Rigby
Ahh - I *wondered* what Sun meant when they said synthetic instruction.
Blank Xavier
A: 

Sparc64 - alone amongst modern CPUs - implements neither double wide CAS nor LL/SC. As such, implementing lock-free code is problematic. There a solutions, but they are solutions to a problem (ABA) which does not exist on other platforms because of their support for CAS or LL/SC. Furthermore, a range of lock-free algorithms cannot be implemented on Sparce because of this limitation.

Blank Xavier