TreeBarrier ( pid , P) {
unsigned int i , mask;
for ( i = 0, mask = 1; (mask &
pid ) != 0; ++ i , mask <<= 1) {
while (!flag[ pid ][ i ]);
flag[ pid ][ i ] = 0;
}
if ( pid < (P - 1)) {
flag[ pid + mask][ i ] = 1;
while (!flag[ pid ][MAX- 1]);
flag[ pid ][MAX - 1] = 0;
}
for (mask >>= 1; mask > 0; mask >>= 1) {
flag[ pid - mask][MAX-1] = 1;
} |