From: adash <adash> Date: Fri, 3 Apr 2009 22:06:15 +0000 (+0000) Subject: test file for STM X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f17c4d4ee4320ffdb4e7924343174813d4bab367;p=IRC.git test file for STM --- diff --git a/Robust/src/Benchmarks/SingleTM/Tests/Simple.java b/Robust/src/Benchmarks/SingleTM/Tests/Simple.java new file mode 100644 index 00000000..5b5d6976 --- /dev/null +++ b/Robust/src/Benchmarks/SingleTM/Tests/Simple.java @@ -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 index 00000000..6dc374c5 --- /dev/null +++ b/Robust/src/Benchmarks/SingleTM/Tests/makefile @@ -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