test file for STM
authoradash <adash>
Fri, 3 Apr 2009 22:06:15 +0000 (22:06 +0000)
committeradash <adash>
Fri, 3 Apr 2009 22:06:15 +0000 (22:06 +0000)
Robust/src/Benchmarks/SingleTM/Tests/Simple.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/Tests/makefile [new file with mode: 0644]

diff --git a/Robust/src/Benchmarks/SingleTM/Tests/Simple.java b/Robust/src/Benchmarks/SingleTM/Tests/Simple.java
new file mode 100644 (file)
index 0000000..5b5d697
--- /dev/null
@@ -0,0 +1,62 @@
+public class Simple extends Thread {
+  Counting mycount;
+  public Simple(Counting mycount) {
+    this.mycount = mycount;
+  }
+
+  public void run() {
+    for(int i = 0;  i < 10; i++) {
+      atomic {
+        mycount.increment();
+      }
+    }
+  }
+
+  public static void main(String[] args) {
+    Simple[] s;
+    Counting c;
+    int numthreads = 2;
+
+    atomic {
+      c = new Counting();
+      s = new Simple[numthreads];
+      for(int i = 0; i < 2; i++) {
+        s[i] = new Simple(c);
+      }
+    }
+
+    Simple tmp;
+    for(int i = 0; i <  2; i++) {
+      atomic {
+        tmp = s[i];
+      }
+      tmp.start();
+    }
+
+    for(int i = 0; i < 2; i++) {
+      atomic {
+        tmp = s[i];
+      }
+      tmp.join();
+    }
+
+    //print count
+    int finalcount;
+    atomic {
+      finalcount = c.count;
+    }
+    System.printString("Count = "+finalcount+"\n");
+  }
+
+}
+
+class Counting {
+  int count;
+  public Counting() {
+    this.count = 0;
+  }
+
+  public increment() {
+    count = count + 1;
+  }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/Tests/makefile b/Robust/src/Benchmarks/SingleTM/Tests/makefile
new file mode 100644 (file)
index 0000000..6dc374c
--- /dev/null
@@ -0,0 +1,8 @@
+MAINCLASS=Simple
+SRC=${MAINCLASS}.java
+default:
+       ../../../buildscript -singleTM -thread -optimize -mainclass ${MAINCLASS} ${SRC} -o ${MAINCLASS}
+
+clean:
+       rm -rf tmpbuilddirectory
+       rm *.bin