Query and behavior confirmation for pthread_barrier_destroy(3)

Shashank Agarwal agarwalshashank12@gmail.com
Thu Sep 3 11:55:39 GMT 2020


Hello Florian,

Thanks for the confirmation. Please let me know if my understanding is
correct about pthread_barrier_destroy(3).

*A barrier can be destroyed as soon as no threads are blocked on the
barrier.  *

If yes please let me know how I can verify this behaviour.

Thanks and Regards,
Shashank Agarwal

On Thu, Sep 3, 2020 at 5:13 PM Florian Weimer <fweimer@redhat.com> wrote:

> * Shashank Agarwal via Libc-alpha:
>
> > 1. Main thread initializes the pthread barrier with the count as 2.
> > 2. Main thread creates 2 threads.
> > 3. Thread 1 waits for the synchronization at the barrier using
> > pthread_barrier_wait(3).
> > 4. Thread 2 tries to destroy the barrier, and as per the new
> > implementation, it should get block because only 1 thread
> > has performed pthread_barrier_wait(3).
>
> This test is invalid according to POSIX, which says:
>
> | The results are undefined if pthread_barrier_destroy() is called when
> | any thread is blocked on the barrier
>
> I do not believe such a test would be valid for the glibc
> implementation.
>
> Thanks,
> Florian
>
>

-- 
shashank


More information about the Libc-alpha mailing list