Revision: 15728
http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=15728&view=revAuthor: rgarner
Date: 2009-07-21 03:43:26 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
Some refactoring, Javadoc etc.
Modified Paths:
--------------
rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/JavaThreadModel.java
Modified: rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/JavaThreadModel.java
===================================================================
--- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/JavaThreadModel.java 2009-07-21 03:36:49 UTC (rev 15727)
+++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/JavaThreadModel.java 2009-07-21 03:43:26 UTC (rev 15728)
@@ -17,7 +17,6 @@
import java.util.Set;
import org.mmtk.harness.Collector;
-import org.mmtk.harness.Harness;
import org.mmtk.harness.Mutator;
import org.mmtk.harness.lang.Env;
import org.mmtk.harness.lang.Trace;
@@ -33,18 +32,25 @@
}
/**
- * Count of collector threads scheduled through scheduleCollector(Schedulable)
+ * Collector threads scheduled through #scheduleCollector(Schedulable)
*/
- Set<CollectorContextThread> collectorTestThreads =
- Collections.synchronizedSet(new HashSet<CollectorContextThread>());
+ Set<CollectorThread> collectorThreads =
+ Collections.synchronizedSet(new HashSet<CollectorThread>());
/**
+ * Mutator threads scheduled through scheduleMutator(Schedulable)
+ */
+ Set<MutatorThread> mutatorThreads =
+ Collections.synchronizedSet(new HashSet<MutatorThread>());
+
+ /**
* Create a new mutator thread
*/
@Override
public void scheduleMutator(Schedulable code) {
Trace.trace(Item.SCHEDULER, "Scheduling new mutator");
- Thread t = new MutatorThread(code);
+ MutatorThread t = new MutatorThread(code);
+ mutatorThreads.add(t);
t.start();
}
@@ -54,18 +60,21 @@
@Override
public void scheduleCollector() {
Trace.trace(Item.SCHEDULER, "Scheduling new collector");
- Thread t = new CollectorThread();
+ CollectorThread t = new CollectorThread();
+ collectorThreads.add(t);
t.start();
}
/**
* Create a new collector thread with a specific Schedulable
+ *
+ * Used for scheduling unit tests in collector context
*/
@Override
public Thread scheduleCollector(Schedulable code) {
Trace.trace(Item.SCHEDULER, "Scheduling new collector");
CollectorContextThread t = new CollectorContextThread(code);
- collectorTestThreads.add(t);
+ collectorThreads.add(t);
t.start();
return t;
}
@@ -83,10 +92,12 @@
}
}
+ @Override
public Log currentLog() {
return currentMMTkThread().getLog();
}
+ @Override
public Mutator currentMutator() {
assert Thread.currentThread() instanceof MutatorThread : "Current thread is not a Mutator";
return ((MutatorThread)Thread.currentThread()).env;
@@ -105,6 +116,7 @@
Trace.trace(Item.SCHEDULER, "MutatorThread created");
}
+ @Override
public void run() {
Trace.trace(Item.SCHEDULER, "Env.begin()");
env.begin();
@@ -197,7 +209,7 @@
collectorThreadLocal.set(collector);
waitForGCStart();
code.execute(new Env());
- collectorTestThreads.remove(this);
+ collectorThreads.remove(this);
exitGC();
}
@@ -210,7 +222,7 @@
*/
/** Synchronisation object used for GC triggering */
- private Object trigger = new Object();
+ private final Object trigger = new Object();
/**
* Wait for a GC to complete
@@ -255,7 +267,7 @@
public void triggerGC(int why) {
synchronized (trigger) {
triggerReason = why;
- inGC = Harness.collectors.getValue();
+ inGC = collectorThreads.size();
setState(BEGIN_GC);
trigger.notifyAll();
}
@@ -326,14 +338,20 @@
@Override
public void schedule() {
startRunning();
- // Do nothing - java does it :)
+ /* Wait for the mutators */
+ for (Thread mutator : mutatorThreads) {
+ try {
+ mutator.join();
+ } catch (InterruptedException e) {
+ }
+ }
}
@Override
public void scheduleGcThreads() {
synchronized (trigger) {
startRunning();
- inGC = collectorTestThreads.size();
+ inGC = collectorThreads.size();
setState(GC);
trigger.notifyAll();
while (!isState(MUTATOR)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at:
http://p.sf.net/sfu/Challenge_______________________________________________
Jikesrvm-commits mailing list
Jikesrvm-commits@...
https://lists.sourceforge.net/lists/listinfo/jikesrvm-commits