harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Garner" <robin.gar...@anu.edu.au>
Subject Re: [drlvm][jit] MMTk-style magics implementation in Jitrino.OPT compiler
Date Thu, 21 Sep 2006 23:28:36 GMT
> On 9/21/06, Mikhail Fursov <mike.fursov@gmail.com> wrote:
>> Weldon, Robin
>> thank you for the comments.
>> There are just a few steps left to do before Jitrino.OPT will have
>> usable
>> "unboxed" package implementation.
>> Right now I'm working on atomic operations (prepare/attempt pair), and I
>> do
>> not completely understand the semantic of the 'prepare' method.
>> The "prepareXYZ" method looks like a simple load and is not an atomic
>> operation by itself. Are there any examples that describe these
>> operations
>> in details?
> Robin will correct me if I am wrong.
> I think the idea is that this is a generic API intended to be used for
> accessing "compare and swap" facilities on a bunch of different hardware.
> And the actual hardware has different memory models, different CAS
> semantics, etc.
> Basically the generic facility needed is to first read the CAS target
> memory
> location (this is the "prepare").  If the memory is sitting at a specific
> value (this is the "do something"), then do an "attempt" as follows:
> old_contents =  CAS(expected_specfic_value_that_I_just_read,
> some_new_value,
> target_memory_location)
> If the old_contents are identical to
> expected_specific_value_that_I_just_read, we know that the CAS succeeded.
> In other words, you won the competition.  Otherwise you lost.
> I imagine the following situation in user's code:
>> prepareXYZ()
>> do something
>> attempt()
>> Is this code correct?

You're correct.

The prepare/attempt was designed to match architectures (PPC, Alpha ...)
with a load-locked/store-conditional instruction pair.

The standard code fragment for a synchronized update is

do {
  oldVal = x.prepare();
  newVal = f(oldVal);
} while (!x.attempt(oldVal,newVal));

As an aside, vmmagic should probably have CAS as a primitive rather than
prepare/attempt, but I don't think that's going to happen in the immediate


Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

View raw message