From 161f0bbc72d5abd56c64eee75983d5d19f97afef Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sat, 17 Apr 2010 00:50:03 +0000 Subject: [PATCH] my changes --- .../Recovery/Game/recovery/Barrier.java | 113 +++++++++++------- .../Recovery/Game/recovery/RainForest.java | 14 +-- 2 files changed, 74 insertions(+), 53 deletions(-) diff --git a/Robust/src/Benchmarks/Recovery/Game/recovery/Barrier.java b/Robust/src/Benchmarks/Recovery/Game/recovery/Barrier.java index fc9de580..1254134c 100644 --- a/Robust/src/Benchmarks/Recovery/Game/recovery/Barrier.java +++ b/Robust/src/Benchmarks/Recovery/Game/recovery/Barrier.java @@ -1,10 +1,19 @@ public class Barrier extends Thread { threadinfo[] tinfo; int numthreads; + GameMap[][] land; + int maxage; + int rows; + int cols; - public Barrier(int n, threadinfo[] tinfo) { - numthreads=n; - this.tinfo=tinfo; + public Barrier(int n, threadinfo[] tinfo, GameMap[][] land, int maxage, int rows, int cols) { + this.land=land; + this.maxage=maxage; + this.rows=rows; + this.cols=cols; + this.numthreads=n; + + this.tinfo=global new threadinfo[n]; } /** @@ -14,7 +23,7 @@ public class Barrier extends Thread { ** @param rows The number of rows in the map ** @param cols The number of columns in the map **/ - public void updateAge(GameMap[][] land, int maxage, int rows, int cols) { + public void updateAge() { int countTrees = 0; //System.out.println("updateAge -> maxAge : "+maxage + " rows : " + rows + " cols : "+ cols); for(int i = 0; i Dead\n"); - continue; - } - int y; - atomic { - y=tinfo[i].counter; - } + boolean cont=true; + int count=0; - //System.printString("i= " + i + " i's count= " + y + " threadid= " + threadid + " mycount= " + x); + /* Here we see if we are the first non-failed machine...if so, we operate the barrier...if not we wait for our signal */ + while(cont&&count!=threadid) { + if (Thread.getStatus(count)==-1) { + count++; + } else { + atomic { + if (tinfo[threadid].status==1) + cont=false; + } + } + } - while(y0) { + //we are doing the barrier + for(int i=threadid+1; i0) //small sleep here sleep(100); - atomic { - y = tinfo[i].counter; - } - } + } + //everyone has reached barrier + atomic { + //update map + b.updateAge(); + // } + //think a single transaction is fine here.... + // atomic { + for(int i=threadid+1; i