Mohammad Akhlaghi wrote:
I have made extensive use of the pthread_barrier_* types and functions
for the parallel processing parts of gnuastro. But I found out Gnulib
doesn't include them. I wanted to see if it would be possible for you to
include these in the Gnulib version of pthread. Using a pthread_barrier
is simpler than using a mutex and condition variable together when the
jobs are completely independent.
Which one of these two implementation approaches would be better:
a) using the same design as glibc,
https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/DESIGN-barrier.txt;hb=HEAD
possibly with an additional lock for the atomic increment?
b) using two semaphores, as in
http://stackoverflow.com/questions/6331301/implementing-an-n-process-barrier-using-semaphores
(possibly replacing the second semaphore with a pthread_cond_t ?)
[I'm not going to implement it. Just trying to give food for thought.]
Bruno