start of new file
[IRC.git] / Robust / src / Benchmarks / Prefetch / Em3d / dsm / Barrier.java
index 2f0f05dde4d3fcb4f7dabd5fac8b0baa2ad1bc1c..8429289d6d9dca15cab4c5133fbd8f225593afc4 100644 (file)
@@ -19,10 +19,7 @@ public class Barrier {
 
   public static void enterBarrier(Barrier b) {
     int tmp;
-    boolean retry=true;
-
-    if(b.numthreads == 1)
-      return;
+    boolean retry=true, ret1=false, ret2=true;;
 
     do {
       atomic {
@@ -30,23 +27,26 @@ public class Barrier {
           b.entercount++;
           tmp = b.entercount;
           if (tmp==b.numthreads) {
-            b.cleared=true;
+            if(b.numthreads > 1)
+              b.cleared=true;
             b.entercount--;
-            return;
+            ret1 = true;
           }
           retry=false;
         }
       }
     } while(retry);
-
-    while(true) {
+    if (ret1) {
+      return;
+    }
+    while(ret2) {
       atomic {
         if (b.cleared) {
           b.entercount--;
           int count = b.entercount;
           if (count==0)
             b.cleared=false;
-          return;
+          ret2=false;
         }
       }
     }