Some implementations of Pthreads define barriers. The function
initializes a barrier object, barrier p. As usual, we’ll ignore the second argument and just pass in NULL. The last argument indicates the number of threads
that must reach the barrier before they can continue. The barrier itself is a call
to the function
int pthread barrier wait(
pthread barrier t∗ barrier p /∗ in/out ∗/);
As with most other Pthreads objects, there is a destroy function
int pthread barrier destroy(
pthread barrier t∗ barrier p /∗ in/out ∗/);
Modify one of the barrier programs from the book’s website so that it uses a
Pthreads barrier. Find a system with a Pthreads implementation that includes
barrier and run your program with various numbers of threads. How does its
performance compare to the other implementations?