From 0cf9994ab182f21449ad5642f1ea6ebac33fbf69 Mon Sep 17 00:00:00 2001 From: jihoonl Date: Tue, 23 Feb 2010 01:05:19 +0000 Subject: [PATCH] change --- .../Recovery/Game/recovery/Barrier.java | 17 +++++++++++++---- .../Recovery/Game/recovery/RainForest.java | 9 ++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Robust/src/Benchmarks/Recovery/Game/recovery/Barrier.java b/Robust/src/Benchmarks/Recovery/Game/recovery/Barrier.java index 7178a87d..ec63d471 100644 --- a/Robust/src/Benchmarks/Recovery/Game/recovery/Barrier.java +++ b/Robust/src/Benchmarks/Recovery/Game/recovery/Barrier.java @@ -16,6 +16,7 @@ public class Barrier extends Thread { **/ public void updateAge(GameMap[][] land, int maxage, int rows, int cols) { int countTrees = 0; + //System.out.println("updateAge -> maxAge : "+maxage + " rows : " + rows + " cols : "+ cols); for(int i = 0; i System.println("Tree count= "+countTrees); */ +// System.println("Tree count= "+countTrees); } public static void enterBarrier(int threadid, threadinfo[] tinfo, int numthreads) { @@ -44,13 +45,20 @@ public class Barrier extends Thread { } boolean check = false; atomic { - if(tinfo[i].counter >= tinfo[threadid].counter) { + if(tinfo[i].status != -1) { + if(tinfo[i].counter >= tinfo[threadid].counter) { + check = true; + } + } else { check = true; } } if(!check) { int status = Thread.getStatus(i); if(status==-1) {//Thread is dead + atomic { + tinfo[i].status = -1; + } //System.out.println("DEBUG -> Dead\n"); continue; } @@ -61,7 +69,7 @@ public class Barrier extends Thread { //System.out.println("i= " + i + " i's count= " + y + " threadid= " + threadid + " mycount= " + x); - while(y!=x) { + while(y!=x && (Thread.getStatus(i) != -1)) { //Wait for 100 microseconds sleep(100); atomic { @@ -76,9 +84,10 @@ public class Barrier extends Thread { public class threadinfo { int counter; - int id; + int status; public threadinfo() { counter = 0; + status = 0; } } diff --git a/Robust/src/Benchmarks/Recovery/Game/recovery/RainForest.java b/Robust/src/Benchmarks/Recovery/Game/recovery/RainForest.java index cfaf09c7..79df0e92 100644 --- a/Robust/src/Benchmarks/Recovery/Game/recovery/RainForest.java +++ b/Robust/src/Benchmarks/Recovery/Game/recovery/RainForest.java @@ -81,7 +81,7 @@ public class RainForest extends Thread { //Do N rounds //do one move per round and synchronise for(int i = 0; i