|
Message
From: cvs at opencores.org<cvs@o...>
Date: Mon May 28 18:14:58 CEST 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/05 28:18:14 Added: jop/java/target/src/test/gcinc ForceBlack2White.java SimpVector.java Log: concurrent GC test cases Revision Changes Path 1.1 jop/java/target/src/test/gcinc/ForceBlack2White.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/ForceBlack2White.java?rev=1.1&content-type=text/x-cvsweb-markup Index: ForceBlack2White.java =================================================================== package gcinc; import joprt.RtThread; import com.jopdesign.sys.GC; public class ForceBlack2White { int nr; ForceBlack2White r1, r2; public ForceBlack2White(int i) { nr = i; } static ForceBlack2White nroot; /** * @param args */ public static void main(String[] args) { nroot = new ForceBlack2White(1); nroot.r1 = new ForceBlack2White(2); nroot.r2 = new ForceBlack2White(3); nroot.r1.r1 = new ForceBlack2White(4); new RtThread(2, 100) { public void run() { ForceBlack2White r, tmp; for (;;) { ForceBlack2White abc = new ForceBlack2White(123); r = nroot; // switch pointer to 4 from 2 to 3 tmp = r.r1.r1; waitForNextPeriod(); r.r1.r1 = null; waitForNextPeriod(); r.r2.r1 = tmp; waitForNextPeriod(); check(); waitForNextPeriod(); // switch pointer to 4 from 3 to23 tmp = r.r2.r1; waitForNextPeriod(); r.r2.r1 = null; waitForNextPeriod(); r.r1.r1 = tmp; waitForNextPeriod(); check(); waitForNextPeriod(); // System.out.print('.'); if (abc.nr!=123) { System.out.println("Error in GC (local)"); System.exit(1); } abc = null; waitForNextPeriod(); } } void check() { boolean ok = true; ForceBlack2White r = nroot; if (r.nr!=1) ok = false; if (r.r1.nr!=2) ok = false; if (r.r2.nr!=3) ok = false; if (r.r1.r1!=null && r.r1.r1.nr!=4) ok = false; if (r.r2.r1!=null && r.r2.r1.nr!=4) ok = false; if (!ok) { System.out.println("Error in GC"); System.exit(1); } } }; new RtThread(1, 3456) { public void run() { GC.setConcurrent(); for (;;) { // int time = RtSystem.currentTimeMicro(); System.out.print("G"); GC.gc(); // int now = RtSystem.currentTimeMicro(); // System.out.println(now-time);
// time = now;
// waitForNextPeriod();
}
}
};
RtThread.startMission();
}
}
1.1 jop/java/target/src/test/gcinc/SimpVector.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/SimpVector.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: SimpVector.java
===================================================================
package gcinc;
import java.util.Vector;
public class SimpVector implements Runnable {
Vector v;
int nr;
int size;
public SimpVector(int i) {
size = i;
}
public void run() {
if (nr==0) {
if (size==0) throw new Error("Size is 0");
// create the vector
v = new Vector();
for (int i=0; i<size; ++i) {
v.addElement(new Integer(i));
}
nr = 1;
} else if (nr==1) {
// check the vector
if (v.size()!=size) throw new Error("Size changed");
for (int i=0; i<size; ++i) {
Object o = v.elementAt(i);
if (o==null) throw new Error("Null pointer to element");
Integer it = (Integer) o;
int iv = it.intValue();
if (iv!=i) throw new Error("Value is wrong");
}
nr = 0;
}
}
static SimpVector a,b,c;
/**
* @param args
*/
public static void main(String[] args) {
a = new SimpVector(100);
b = new SimpVector(25);
c = new SimpVector(999);
for (;;) {
a.run();
b.run();
c.run();
}
}
}
|
 |