org.jikesrvm.mm.mminterface
Class Handshake

java.lang.Object
  extended by org.jikesrvm.mm.mminterface.Handshake

public class Handshake
extends Object

Handshake handles mutator requests to initiate a collection, and wait for a collection to complete. It implements the process of suspending all mutator threads executing in Java and starting all the GC threads (CollectorThreads) for the processors that will be participating in a collection. This may not be all processors, if we exclude those executing in native code. Because the threading strategy within RVM is currently under revision, the logic here is also changing and somewhat "messy".

See Also:
CollectorThread

Field Summary
private  int collectorThreadsParked
           
 int gcTrigger
           
private  Monitor lock
          Instance variables
protected  boolean requestFlag
           
static int verbose
          Class variables
 
Constructor Summary
Handshake()
           
 
Method Summary
 void boot()
           
(package private)  void parkCollectorThread()
           
private  boolean request(int why)
          Called by mutators to request a garbage collection.
 void requestAndAwaitCompletion(int why)
          Called by mutators to request a garbage collection and wait for it to complete.
 void requestAndContinue(int why)
          Called by mutators to request an asynchronous garbage collection.
 void reset()
           
 void waitForGCToFinish()
          Call this if you know that a GC request has already been made and you'd like to wait on that GC to finish - presumably because you're trying to allocate and cannot reasonably do so before GC is done.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

verbose

public static final int verbose
Class variables

See Also:
Constant Field Values

lock

private Monitor lock
Instance variables


requestFlag

protected boolean requestFlag

gcTrigger

public int gcTrigger

collectorThreadsParked

private int collectorThreadsParked
Constructor Detail

Handshake

public Handshake()
Method Detail

boot

public void boot()

waitForGCToFinish

public void waitForGCToFinish()
Call this if you know that a GC request has already been made and you'd like to wait on that GC to finish - presumably because you're trying to allocate and cannot reasonably do so before GC is done. Note, there CANNOT be a GC safe point between when you realize that there is already a GC request and when you call this method!


requestAndAwaitCompletion

public void requestAndAwaitCompletion(int why)
Called by mutators to request a garbage collection and wait for it to complete. Waiting is actually just yielding the processor to schedule the collector thread, which will disable further thread switching on the processor until it has completed the collection.


requestAndContinue

public void requestAndContinue(int why)
Called by mutators to request an asynchronous garbage collection. After initiating a GC (if one is not already initiated), the caller continues until it yields to the GC. It may thus make this call at an otherwise unsafe point.


reset

public void reset()

parkCollectorThread

void parkCollectorThread()

request

private boolean request(int why)
Called by mutators to request a garbage collection.

Returns:
true if the completion flag is not already set.