In barrier.c at Chap 31(31/barrier.c), you use two variable in barrier_t, but I think you can just keep num_threads and use num_threads--; when a thread enter barrier, then test num_threads==0 . Besides, in fact test of num_threads is not in critical section, so you can put Sem_post(b->modCounter); before the test.
In barrier.c at Chap 31(31/barrier.c), you use two variable in barrier_t, but I think you can just keep
num_threads
and usenum_threads--;
when a thread enter barrier, then testnum_threads==0
. Besides, in fact test ofnum_threads
is not in critical section, so you can putSem_post(b->modCounter);
before the test.