#include #include using namespace std; #include "mbarrier.h" const int nproc = 5; Barrier* b; // declare a barrier. int main() { int i; int id; int shareid; b = (Barrier*)shareint(sizeof(Barrier), shareid); // Note that the size of barrier is 16 bytes. // Four integers defined in the barrier. b->Barrierinit(6); //Initialize the barrier to // block 6 processes. id=process_fork(6); //STEP I of the computation using 6 processes cout<WaitAtBarrier(); // Block the processes till // all of them reach this point cout<WaitAtBarrier(); //Reuse the barrier to block all the processes cout<SemRelease(); // Release Semaphore used in // the barrier return 0; }