Hi Bruno,
Thanks for introducing the two cases, it is very interesting. I
understand the first option (glibc's implementation) better, but if the
second is a more fundamental approach maybe that should be used. As long
as all the pthread_barrier functions become available.
I am an astronomy PhD student and have not officially had any computer
science courses (although I am very interested to learn, as I have until
now). I will definitely read the "Little book on Semaphores" to
understand them better.
Thank you for the links,
Mohammad
On 03/08/2015 08:51 PM, Bruno Haible wrote:
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