Query and behavior confirmation for pthread_barrier_destroy(3)

Shashank Agarwal agarwalshashank12@gmail.com
Thu Sep 3 09:07:16 GMT 2020


Hello,

Greetings of the day.

As per current implementation, a barrier can be destroyed as soon as no
threads are blocked on the barrier. In order to confirm the behaviour, I
have created a test case attached to this email as
pthread_barrier_destroy_sample.c.

The Description of the test case is as follows -

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).
5. After 10 seconds of sleep Main thread calls pthread_barrier_wait(3) and
thread 2 returns from the pthread_barrier_destroy(3)
successfully. But thread 1 still waiting at the barrier for the
synchronization.

As per our understanding thread, 1 should successfully return from
pthread_barrier_wait(2) and it should not block as this is not the graceful
behaviour.

Please let me know your views on the same.

Regards

Shashank Agarwal
HCL Technologies Limited

shashank_agarwal@hcl.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pthread_barrier_destroy_sample.c
Type: application/octet-stream
Size: 1934 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20200903/d8f28b7d/attachment.obj>


More information about the Libc-alpha mailing list