projects
/
IRC.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
change mid arrays
[IRC.git]
/
Robust
/
src
/
Benchmarks
/
Prefetch
/
Moldyn
/
java
/
Barrier.java
1
public class Barrier {
2
int numthreads;
3
int entercount;
4
boolean cleared;
5
6
public Barrier(int n) {
7
numthreads=n;
8
cleared = false;
9
}
10
11
public Barrier() {
12
13
}
14
15
public void reset() {
16
cleared = false;
17
entercount = 0;
18
}
19
20
public static void enterBarrier(Barrier b) {
21
int tmp;
22
boolean retry=true;
23
24
do {
25
if (!b.cleared) {
26
b.entercount++;
27
tmp = b.entercount;
28
if (tmp==b.numthreads) {
29
if(b.numthreads > 1)
30
b.cleared=true;
31
b.entercount--;
32
return;
33
}
34
retry=false;
35
}
36
} while(retry);
37
38
while(true) {
39
if (b.cleared) {
40
b.entercount--;
41
int count = b.entercount;
42
if (count==0)
43
b.cleared=false;
44
return;
45
}
46
}
47
}
48
}