File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
tests/regression/82-barrier Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ // NOMAC PARAM: --set ana.activated[+] 'pthreadBarriers'
2+ #include <pthread.h>
3+ #include <stdio.h>
4+ #include <unistd.h>
5+
6+ int g ;
7+
8+ pthread_barrier_t barrier ;
9+ pthread_mutex_t mutex ;
10+
11+ void * thread_func (void * arg ) {
12+ // Some initialization code
13+ pthread_barrier_wait (& barrier );
14+
15+ pthread_mutex_lock (& mutex );
16+ g = 5 ; //NORACE
17+ pthread_mutex_unlock (& mutex );
18+
19+ return NULL ;
20+ }
21+
22+
23+
24+ int main (int argc , char const * argv [])
25+ {
26+ pthread_t worker1 , worker2 ;
27+
28+ pthread_barrier_init (& barrier , NULL , 3 );
29+
30+ pthread_create (& worker1 , NULL , thread_func , NULL );
31+ pthread_create (& worker2 , NULL , thread_func , NULL );
32+
33+ g = 8 ; //NORACE
34+
35+ pthread_barrier_wait (& barrier );
36+ return 0 ;
37+ }
You can’t perform that action at this time.
0 commit comments