// testingm.cpp // This tests multiple use of the same barrier #include using namespace std; #include #include "utility.h" #include "sbarrier.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(5); //Initialize the barrier to // block 5 processes. id=process_fork(5); //STEP I of the computation using 5 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; }