jQuery in Action, 2nd edition
The moose likes Threads and Synchronization and the fly likes What if CAS not supported by Processor Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "What if CAS not supported by Processor" Watch "What if CAS not supported by Processor" New topic
Author

What if CAS not supported by Processor

Kartik Patel
Ranch Hand

Joined: Sep 12, 2005
Posts: 73
Java 5 uses atomic object (Lock) to provide alternative to synchronization. Lock is nothing but the hardware level constructs of CAS. What is some processors do not support CAS and I have code with Lock object being used in it?

I think it will break. Any idea?
[ April 14, 2008: Message edited by: Kartik Patel ]

Chop your own wood, and it will warm you twice. - Henry Ford
chatchai chailuecha
Greenhorn

Joined: Dec 14, 2006
Posts: 18
In "Java concurrency in practice" by Brian goetz

15.2.3. CAS Support in the JVM
On platforms supporting CAS, the runtime inlines them into the appropriate machine instruction(s); in the worst case, if a CAS-like instruction is not available the JVM uses a spin lock.


The javadoc about compareAndSet operation states that:

The specifications of these methods enable implementations to employ efficient machine-level atomic instructions that are available on contemporary processors. However on some platforms, support may entail some form of internal locking. Thus the methods are not strictly guaranteed to be non-blocking


I guess the spin lock will be used instead

[ April 14, 2008: Message edited by: chatchai chailuecha ]

[ April 14, 2008: Message edited by: chatchai chailuecha ]
[ April 14, 2008: Message edited by: chatchai chailuecha ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: What if CAS not supported by Processor
 
Similar Threads
Static Lock and Instance Lock
Corejava Question ??
Integrating CAS with Spring Security
Thread doubt
CAS Integration