|
Message
From: cvs at opencores.org<cvs@o...>
Date: Mon Jul 30 12:57:53 CEST 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/07 30:12:57 Added: jop/java/target/src/test/gcinc Issue.java myList.java SimpGC3.java typeA.java typeB.java Log: new GC test case Revision Changes Path 1.1 jop/java/target/src/test/gcinc/Issue.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/Issue.java?rev=1.1&content-type=text/x-cvsweb-markup Index: Issue.java =================================================================== package gcinc; import java.util.Vector; import com.jopdesign.sys.Const; import com.jopdesign.sys.GC; import com.jopdesign.sys.Native; import joprt.RtThread; public class Issue { static class HFThread extends RtThread { public HFThread(int prio, int us) { super(prio, us); period = us; } int period; int expected; int max, min; int cnt; public void run() { int t; waitForNextPeriod(); t = Native.rdMem(Const.IO_US_CNT); expected = t+period; for (;;) { waitForNextPeriod(); t = Native.rdMem(Const.IO_US_CNT); int diff = t-expected; if (diff>max) { max = diff; } else if (diff<min) { min = diff; } if (++cnt==1000000) { result(); } expected = expected+period; work(); } } void work() { // nothing for the HF thread } void result() { System.out.println("max="+max); System.out.println("min="+min); for (;;); } } // static Vector v; static SimpleList sl; static class MFThread extends HFThread { int nr; public MFThread(int prio, int us) { super(prio, us); } void work() { sl.append(new Integer(nr)); // synchronized (v) { // v.addElement(new Integer(nr)); // } ++nr; } } static class LFThread extends HFThread { int expNr; public LFThread(int prio, int us) { super(prio, us); } void work() {
Object o;
while ((o = sl.remove())!=null) {
if (((Integer) o).intValue()!=expNr) {
System.out.println("List problem");
}
++expNr;
}
// int size;
// synchronized (v) {
// size = v.size();
// }
// while (size!=0) {
// Object o;
// synchronized (v) {
// o = v.remove(0);
// }
// if (((Integer) o).intValue()!=expNr) {
// System.out.println("Vector problem");
// }
// ++expNr;
// synchronized (v) {
// size = v.size();
// }
// }
}
}
static class GCThread extends RtThread {
public GCThread() {
super(1, PERIOD_GC);
GC.setConcurrent();
}
public void run() {
for (;;) {
System.out.print("G");
GC.gc();
waitForNextPeriod();
}
}
}
static class LogThread extends RtThread {
public LogThread(int prio, int us) {
super(prio, us);
}
public void run() {
for (;;) {
waitForNextPeriod();
System.out.println();
if (hft!=null) {
System.out.print("hft max=");
System.out.println(hft.max);
System.out.print("hft min=");
System.out.println(hft.min);
}
if (mft!=null) {
System.out.print("mft max=");
System.out.println(mft.max);
System.out.print("mft min=");
System.out.println(mft.min);
}
}
}
}
static HFThread hft;
static MFThread mft;
// 200 is without jitter when running it alone
// 500 without jitter when a second dummy thread runs
// change to 200us on the 100 MHz version
// at 100 MHz, RtThreadImp TIM_OFF at 2:
// 200 us without jitter when run alone
// with output thread 10 us
// with prod/cons threads (no GC) 16 us
// with GC 72 us (77 us)
// public static final int PERIOD_HIGH = 30;
// public static final int PERIOD_MEDIUM = 500;
// public static final int PERIOD_LOW = 10000;
// public static final int PERIOD_GC = 200000;
public static final int PERIOD_HIGH = 107;
public static final int PERIOD_MEDIUM = 1009;
public static final int PERIOD_LOW = 10853;
public static final int PERIOD_GC = 200183;
/**
* @param args
*/
public static void main(String[] args) {
// v = new Vector(20);
sl = new SimpleList();
hft = new HFThread(5, PERIOD_HIGH);
mft = new MFThread(4, PERIOD_MEDIUM);
new LFThread(3, PERIOD_LOW);
new GCThread();
new LogThread (2, 1000*1000);
RtThread.startMission();
// that one is mandatary to get low latency!
// check RtThreadImpl why.
for (;;);
}
}
1.1 jop/java/target/src/test/gcinc/myList.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/myList.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: myList.java
===================================================================
package gcinc;
import java.util.Iterator;
public class myList implements Iterator {
class Item{
int id;
Object item;
Item nextItem;
}
public myList(){}
public Item lastItem,firstItem,currentItem;
public int size;
public void add(Object o) {
size++;
Item e = new Item();
e.item = o;
//add the element at the end of the list
synchronized (this) {
if (lastItem!=null) {
lastItem.nextItem= e;
} else {
firstItem = e;
}
lastItem = e;
}
}
public int size(){
return size;
}
//Iterator interface methods
public Object next() {
if (currentItem==null){
currentItem=firstItem;
}
Object currentObject=currentItem.item;
//make iteration cyclic
if(currentItem.nextItem!=null){
currentItem=currentItem.nextItem;
}else{
currentItem=firstItem;
}
return currentObject;
}
public boolean hasNext() {
if(currentItem.nextItem==null){
return false;
}else {
return true;
}
}
public void remove(){
}
}
1.1 jop/java/target/src/test/gcinc/SimpGC3.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/SimpGC3.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: SimpGC3.java
===================================================================
package gcinc;
public class SimpGC3 implements Runnable {
public myList list;
int length,nr;
public SimpGC3(int i) {
length = i;
}
public void run() {
if (nr==0) {
if (length==0) throw new Error("Length is 0");
// create the List
list= new myList();
for (int i=1; i<length/2 + 1; ++i) {
list.add(new typeA(i));
list.add(new typeB(i));
}
nr = 1;
} else if (nr==1) {
System.out.println(length);
// check the list
if (list.size()!=length) throw new Error("Size changed");
testObject to;
to=(testObject)list.next();
for (int i=1; i<length/2+1; ++i) {
if (to==null) throw new Error("Null pointer to element");
if (!to.testYourself(i)) throw new Error("Value is wrong");
to=(testObject)list.next();
if (to==null) throw new Error("Null pointer to element");
if (!to.testYourself(i)) throw new Error("Value is wrong");
to=(testObject)list.next();
}
nr = 0;
}
}
static SimpGC3 a,b,c;
/**
* @param args
*/
public static void main(String[] args) {
a = new SimpGC3(10);
b = new SimpGC3(26);
c = new SimpGC3(10);
//GC.setConcurrent();
for (;;) {
a.run();
b.run();
c.run();
System.out.println("I'm running");
}
}
}
1.1 jop/java/target/src/test/gcinc/typeA.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/typeA.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: typeA.java
===================================================================
package gcinc;
public class typeA implements testObject{
private int myInt1,myInt2,myInt3;
public boolean testYourself(int i){
boolean isOk;
isOk=myInt1==i && myInt2/i==i && (myInt3-myInt2)/i==i;
return isOk;
//return true;
}
public typeA(int i){
myInt1=i;
myInt2=i*i;
myInt3=i*i + myInt2;
}
}
1.1 jop/java/target/src/test/gcinc/typeB.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/typeB.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: typeB.java
===================================================================
package gcinc;
public class typeB implements testObject{
int myInt1,myInt2,myInt3;
public boolean testYourself(int i){
boolean isOk;
isOk= (myInt1/i)/i==i && (myInt2-i)/4==i && (((myInt3-6)/i)-5)/(4*i)==i;
return true;
}
public typeB(int i){
myInt1=i*i*i;
myInt2=4*i+i;
myInt3=4*i*i+5*i+6;
}
}
|
 |