org.jikesrvm.scheduler
Class Synchronization

java.lang.Object
  extended by org.jikesrvm.scheduler.Synchronization

public class Synchronization
extends Object

Class to provide synchronization methods where java language synchronization is insufficient and Magic.prepare and Magic.attempt are at too low a level.


Constructor Summary
Synchronization()
           
 
Method Summary
static int fetchAndAdd(Object base, Offset offset, int increment)
           
static Address fetchAndAddAddressWithBound(Object base, Offset offset, int increment, Address bound)
           
static int fetchAndDecrement(Object base, Offset offset, int decrement)
           
static int fetchAndStore(Object base, Offset offset, int newValue)
           
static Address fetchAndStoreAddress(Object base, Offset offset, Address newValue)
           
static Address fetchAndSubAddressWithBound(Object base, Offset offset, int decrement, Address bound)
           
static boolean testAndSet(Object base, Offset offset, int newValue)
           
static boolean tryCompareAndSwap(Object base, Offset offset, Address testValue, Address newValue)
          Atomically swap test value to new value in the specified object and the specified field
static boolean tryCompareAndSwap(Object base, Offset offset, int testValue, int newValue)
          Atomically swap test value to new value in the specified object and the specified field
static boolean tryCompareAndSwap(Object base, Offset offset, long testValue, long newValue)
          Atomically swap test value to new value in the specified object and the specified field
static boolean tryCompareAndSwap(Object base, Offset offset, Object testValue, Object newValue)
          Atomically swap test value to new value in the specified object and the specified field
static boolean tryCompareAndSwap(Object base, Offset offset, Word testValue, Word newValue)
          Atomically swap test value to new value in the specified object and the specified field
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Synchronization

public Synchronization()
Method Detail

tryCompareAndSwap

public static boolean tryCompareAndSwap(Object base,
                                        Offset offset,
                                        int testValue,
                                        int newValue)
Atomically swap test value to new value in the specified object and the specified field

Parameters:
base - object containing field
offset - position of field
testValue - expected value of field
newValue - new value of field
Returns:
true=> successful swap, false=> field not equal to testValue

tryCompareAndSwap

public static boolean tryCompareAndSwap(Object base,
                                        Offset offset,
                                        long testValue,
                                        long newValue)
Atomically swap test value to new value in the specified object and the specified field

Parameters:
base - object containing field
offset - position of field
testValue - expected value of field
newValue - new value of field
Returns:
true=> successful swap, false=> field not equal to testValue

tryCompareAndSwap

public static boolean tryCompareAndSwap(Object base,
                                        Offset offset,
                                        Word testValue,
                                        Word newValue)
Atomically swap test value to new value in the specified object and the specified field

Parameters:
base - object containing field
offset - position of field
testValue - expected value of field
newValue - new value of field
Returns:
true=> successful swap, false=> field not equal to testValue

tryCompareAndSwap

public static boolean tryCompareAndSwap(Object base,
                                        Offset offset,
                                        Address testValue,
                                        Address newValue)
Atomically swap test value to new value in the specified object and the specified field

Parameters:
base - object containing field
offset - position of field
testValue - expected value of field
newValue - new value of field
Returns:
true=> successful swap, false=> field not equal to testValue

tryCompareAndSwap

public static boolean tryCompareAndSwap(Object base,
                                        Offset offset,
                                        Object testValue,
                                        Object newValue)
Atomically swap test value to new value in the specified object and the specified field

Parameters:
base - object containing field
offset - position of field
testValue - expected value of field
newValue - new value of field
Returns:
true=> successful swap, false=> field not equal to testValue

testAndSet

public static boolean testAndSet(Object base,
                                 Offset offset,
                                 int newValue)

fetchAndStore

public static int fetchAndStore(Object base,
                                Offset offset,
                                int newValue)

fetchAndStoreAddress

public static Address fetchAndStoreAddress(Object base,
                                           Offset offset,
                                           Address newValue)

fetchAndAdd

public static int fetchAndAdd(Object base,
                              Offset offset,
                              int increment)

fetchAndDecrement

public static int fetchAndDecrement(Object base,
                                    Offset offset,
                                    int decrement)

fetchAndAddAddressWithBound

public static Address fetchAndAddAddressWithBound(Object base,
                                                  Offset offset,
                                                  int increment,
                                                  Address bound)

fetchAndSubAddressWithBound

public static Address fetchAndSubAddressWithBound(Object base,
                                                  Offset offset,
                                                  int decrement,
                                                  Address bound)