Revision: 15737
http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=15737&view=revAuthor: rgarner
Date: 2009-07-23 01:48:35 +0000 (Thu, 23 Jul 2009)
Log Message:
-----------
Fixes for unit test bugs
Modified Paths:
--------------
rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/CollectorContextThread.java
rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/CollectorThread.java
rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/JavaThreadModel.java
rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/MutatorThread.java
Modified: rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/CollectorContextThread.java
===================================================================
--- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/CollectorContextThread.java 2009-07-23 01:47:42 UTC (rev 15736)
+++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/CollectorContextThread.java 2009-07-23 01:48:35 UTC (rev 15737)
@@ -27,10 +27,10 @@
@Override
public void run() {
- JavaThreadModel.collectorThreadLocal.set(collector);
+ JavaThreadModel.setCurrentCollector(collector);
model.waitForGCStart();
code.execute(new Env());
- model.collectorThreads.remove(this);
+ model.removeCollector(this);
model.exitGC();
}
Modified: rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/CollectorThread.java
===================================================================
--- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/CollectorThread.java 2009-07-23 01:47:42 UTC (rev 15736)
+++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/CollectorThread.java 2009-07-23 01:48:35 UTC (rev 15737)
@@ -31,7 +31,7 @@
@Override
public void run() {
- JavaThreadModel.collectorThreadLocal.set(collector);
+ JavaThreadModel.setCurrentCollector(collector);
collector.run();
}
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-23 01:47:42 UTC (rev 15736)
+++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/JavaThreadModel.java 2009-07-23 01:48:35 UTC (rev 15737)
@@ -34,13 +34,13 @@
/**
* Collector threads scheduled through #scheduleCollector(Schedulable)
*/
- Set<CollectorThread> collectorThreads =
+ private final Set<CollectorThread> collectorThreads =
Collections.synchronizedSet(new HashSet<CollectorThread>());
/**
* Mutator threads scheduled through scheduleMutator(Schedulable)
*/
- Set<MutatorThread> mutatorThreads =
+ private final Set<MutatorThread> mutatorThreads =
Collections.synchronizedSet(new HashSet<MutatorThread>());
/**
@@ -79,6 +79,10 @@
return t;
}
+ void removeCollector(CollectorThread c) {
+ collectorThreads.remove(c);
+ }
+
private MMTkThread currentMMTkThread() {
return ((MMTkThread)Thread.currentThread());
}
@@ -132,6 +136,7 @@
private void incActiveMutators() {
activeMutators++;
+ count.notify();
}
private void decActiveMutators() {
@@ -147,7 +152,8 @@
* join the GC (because we are required to trigger it) and then exit.
* Otherwise, just decrement the mutator count and leave.
*/
- void leaveMutatorPool() {
+ void leaveMutatorPool(MutatorThread m) {
+ Trace.trace(Item.SCHEDULER, "%d Leaving mutator pool", Thread.currentThread().getId());
synchronized (count) {
boolean lastToGC = (mutatorsWaitingForGC == (activeMutators - 1));
if (!lastToGC) {
@@ -161,7 +167,7 @@
mutatorsWaitingForGC--;
decActiveMutators();
}
-
+ mutatorThreads.remove(m);
}
/** Synchronisation object used for GC triggering */
@@ -246,26 +252,20 @@
}
}
- /**
- * The number of mutators waiting for a collection to proceed.
- */
+ /** Object used for synchronizing mutatorsWaitingForGC and activeMutators */
+ private static final Object count = new Object();
+
+ /** The number of mutators waiting for a collection to proceed. */
protected int mutatorsWaitingForGC;
/** The number of collectors executing GC */
protected int inGC;
- /**
- * The number of mutators currently executing in the system.
- */
+ /** The number of mutators currently executing in the system. */
protected int activeMutators;
- /**
- * Object used for synchronizing the number of mutators waiting for a gc.
- */
- public static final Object count = new Object();
-
/** Thread access to current collector */
- public static final ThreadLocal<Collector> collectorThreadLocal = new ThreadLocal<Collector>();
+ private static final ThreadLocal<Collector> collectorThreadLocal = new ThreadLocal<Collector>();
@Override
public int rendezvous(int where) {
@@ -277,6 +277,10 @@
return collectorThreadLocal.get();
}
+ static void setCurrentCollector(Collector c) {
+ collectorThreadLocal.set(c);
+ }
+
@Override
public JavaLock newLock(String name) {
return new org.mmtk.harness.scheduler.javathreads.JavaLock(name);
@@ -289,14 +293,24 @@
@Override
public void schedule() {
startRunning();
- /* Wait for the mutators */
+ /* Wait for the mutators to start */
+ while (mutatorThreads.size() > activeMutators) {
+ synchronized (count) {
+ try {
+ count.wait();
+ } catch (InterruptedException e) {
+ }
+ Trace.trace(Item.SCHEDULER,"Active mutators = "+activeMutators);
+ }
+ }
+ /* Wait for the mutators to exit */
while (activeMutators > 0) {
synchronized (count) {
try {
count.wait();
} catch (InterruptedException e) {
}
- System.err.println("Active mutators = "+activeMutators);
+ Trace.trace(Item.SCHEDULER,"Active mutators = "+activeMutators);
}
}
}
Modified: rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/MutatorThread.java
===================================================================
--- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/MutatorThread.java 2009-07-23 01:47:42 UTC (rev 15736)
+++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/scheduler/javathreads/MutatorThread.java 2009-07-23 01:48:35 UTC (rev 15737)
@@ -65,7 +65,7 @@
}
private void endMutator() {
- model.leaveMutatorPool();
+ model.leaveMutatorPool(this);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Jikesrvm-commits mailing list
Jikesrvm-commits@...
https://lists.sourceforge.net/lists/listinfo/jikesrvm-commits