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.
$