• Description: Please refer to section 6.8.
  • Deadline: 2010 May 6 00:05am
  • Put your file(s) under ~/usp-982/exer7
  • This exercise asks you to write a barrier-server and a function used in barrier-client.
    The pseudo code for client is (The protocal is run three times.)
              void waitatbarrier(char *barrier)
              {
               .....
              }
    
              main(int argc, char *argv[])
              {
                srand48(getpid());
                for(j=0;j<3;j++){
                  sleep((int) (20*drand48()));
                  fprintf(stderr, "Waked up! Waiting for others\n");
                  waitatbarrier(argv[1]);
                  fprintf(stderr, "*** All waked up. *** Do something.\n");
                }
              }
           
    For example:
              $ ./barrier-server ok 4      <----- this is the server
              ....
              $
           
              $ ./barrier-client ok      <---- This is one of the four clients.
              Waked up! Waiting for others
              *** All waked up. *** Do something.
              Waked up! Waiting for others
              *** All waked up. *** Do something.
              Waked up! Waiting for others
              *** All waked up. *** Do something.
              $