[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pthread_barrier type and functions
From: |
Bruno Haible |
Subject: |
Re: pthread_barrier type and functions |
Date: |
Sun, 08 Mar 2015 12:51:25 +0100 |
User-agent: |
KMail/4.8.5 (Linux/3.2.0-64-generic; KDE/4.8.5; x86_64; ; ) |
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