How to find the implementation of barrier functions?

I want to implement a new barrier function.

First of all, I want to know about the default implementation of the barrier. (phtread, linux)

And I find pthread.h (/ usr / include)

But in this file, I cannot find the barrier implementation. only a declaration.

1040 /* Functions to handle barriers.  */                                       
1041 
1042 /* Initialize BARRIER with the attributes in ATTR.  The barrier is
1043    opened when COUNT waiters arrived.  */
1044 extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
1045                  __const pthread_barrierattr_t *__restrict
1046                  __attr, unsigned int __count)
1047      __THROW __nonnull ((1));
1048 
1049 /* Destroy a previously dynamically initialized barrier BARRIER.  */
1050 extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
1051      __THROW __nonnull ((1));
1052 
1053 /* Wait on barrier BARRIER.  */
1054 extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
1055      __THROW __nonnull ((1));

      

Please teach me where the barrier function is implemented.

+3


source to share


2 answers


+4


source


http://ptgmedia.pearsoncmg.com/images/0201633922/sourcecode/barrier.c



See how int barrier_wait uses a counter to keep track of the number of waiting threads.

+2


source







All Articles