sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / tools / lib / lockdep / tests / ABBA_2threads.c
blobcd807d7363611ff4d044fb3390a580c8efad219f
1 #include <stdio.h>
2 #include <pthread.h>
4 pthread_mutex_t a = PTHREAD_MUTEX_INITIALIZER;
5 pthread_mutex_t b = PTHREAD_MUTEX_INITIALIZER;
6 pthread_barrier_t bar;
8 void *ba_lock(void *arg)
10 int ret, i;
12 pthread_mutex_lock(&b);
14 if (pthread_barrier_wait(&bar) == PTHREAD_BARRIER_SERIAL_THREAD)
15 pthread_barrier_destroy(&bar);
17 pthread_mutex_lock(&a);
19 pthread_mutex_unlock(&a);
20 pthread_mutex_unlock(&b);
23 int main(void)
25 pthread_t t;
27 pthread_barrier_init(&bar, NULL, 2);
29 if (pthread_create(&t, NULL, ba_lock, NULL)) {
30 fprintf(stderr, "pthread_create() failed\n");
31 return 1;
33 pthread_mutex_lock(&a);
35 if (pthread_barrier_wait(&bar) == PTHREAD_BARRIER_SERIAL_THREAD)
36 pthread_barrier_destroy(&bar);
38 pthread_mutex_lock(&b);
40 pthread_mutex_unlock(&b);
41 pthread_mutex_unlock(&a);
43 pthread_join(t, NULL);
45 return 0;