-
- int ourcount;
- boolean done=true;
- atomic {
- // Signal this thread has done iteration
- sync[tmpid][0]++;
- ourcount=sync[tmpid][0];
- }
-
- // Wait for neighbours;
- while(done) {
- atomic {
- if ((tmpid==0 || ourcount <= sync[tmpid-1][0])
- &&((tmpid==(numthreads-1))||ourcount<=sync[tmpid+1][0]))
- done=false;
- }
- }