Home | History | Annotate | Download | only in tests
      1 /* All OK */
      2 
      3 #include <pthread.h>
      4 
      5 static pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER;
      6 
      7 static int shared;
      8 
      9 static void *th(void *v)
     10 {
     11 	pthread_mutex_lock(&mx);
     12 	shared++;
     13 	pthread_mutex_unlock(&mx);
     14 
     15 	return 0;
     16 }
     17 
     18 int main()
     19 {
     20 	pthread_t a, b;
     21 
     22 	pthread_mutex_lock(&mx);
     23 	pthread_mutex_unlock(&mx);
     24 
     25 	pthread_create(&a, NULL, th, NULL);
     26 	pthread_create(&b, NULL, th, NULL);
     27 
     28 	pthread_join(a, NULL);
     29 	pthread_join(b, NULL);
     30 
     31 	return 0;
     32 }
     33