Re: [rvm-research] AddressArray with CAS

Eliot Moss <[email protected]>
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
On 5/29/2013 11:01 AM, Nachshon Cohen O wrote:
> Hi
>
> I'm trying to use a wait free queue implementation in the Jikes RVM.
> The implementation holds an array of addresses, and I'd like to apply CAS (compareAndSet) to these addresses.
> For example:
> AddressArray arr = AddressArray.create(10);
> arr[ 3 ].compareAndSet(oldValue, newValue);
>
> It seems that unboxed.AddressArray does not have an option of CAS.
> A normal CAS is implemented only for objects: i.e. Magic.attemptAddress(object, offset, oldValue, newValue);
> However, I don't know how to convert the AddressArray to an object.
>
> Is there a way to use CAS on a specific array element?

An AddressArray is a perfectly good object.  The offset of element
0 is 0 (by design, so that we do not need to add an extra constant
value in for every array access).  You need to know the size of an
Address, but I think there are operations for converting an array
index into an offset, etc.  You also need to be careful not to
access outside the bounds of the actual array, of course.

Regards -- Eliot Moss

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.