FT-Linda implementation of tree barrier from Greg's CP Fig 3.15, except I've combined the continue[i] array into a single continue tuple for a given iteration. Also, a registry tuple must be kept as in the other barrier examples, so recovery can occur from the correct iteration. I've excluded this registry tuple here for brevity. ------------------------------------------------------------------------- leaf(l) # Announce our arrival out("arrive", iteration, l) # Wait for the root to broadcast permission to continue < rd("continue", iter) => skip > end leaf ------------------------------------------------------------------------- interior(i) # Wait for the left to arrive. Leave placeholder so recover can # occur if we fail between withdrawing left and right. < in("arrive", iter, left) => out("in_progress", host, iter, left); > # Wait for left arrive, and when it does remove it, remove left # inprogress, and announce that we've arrived. < in("arrive", iter, right) => in("in_progres", host, iter, left); out("arrive", iter, i); > # Wait for the root to broadcast permission to continue < rd("continue", iter) => skip > end interior ------------------------------------------------------------------------- root(r) # Wait for the left to arrive. Leave placeholder so recovery can # occur if we fail between withdrawing left and right. < in("arrive", iter, left) => out("in_progress", host, iter, left); > # Wait for left arrive, and when it does remove it, remove left # inprogress, and broadcast permission to continue. < in("arrive", iter, right) => in("in_progres", host, iter, left); out("continue", iter); > # Recycle the last iteration's continue tuple. We know that # nobody could need it, since all nodes are in the middle of # the barrier for the current itertation if (iter > 1) < true => in("continue", MINUS(iter,1)); > end root ------------------------------------------------------------------------- Note: the monitor process is similar to that for the barrier. It must regenerate any "arrive" tuples from their "in_progress" placeholders, and then reincarnate the given worker, noting if it was a leaf or an interior or a root (this should be ascertainable from the node index stored in the in_progress tuple, of course).