Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SMPI_is_inited() and smpi_enabled() have the same purpose. Keep only the former.
[simgrid.git] / examples / sthread / pthread-mutex-simple.c
1 /* Simple test code with no bug  */
2
3 #include <pthread.h>
4 #include <stdio.h>
5
6 pthread_mutex_t mutex;
7
8 static void* thread_fun(void* ignore)
9 {
10   pthread_mutex_lock(&mutex);
11   pthread_mutex_unlock(&mutex);
12
13   return NULL;
14 }
15
16 int main(int argc, char* argv[])
17 {
18   fprintf(stderr, "User main is starting\n");
19
20   pthread_mutex_init(&mutex, NULL);
21
22   pthread_t thread1;
23   pthread_t thread2;
24   pthread_create(&thread1, NULL, thread_fun, NULL);
25   fprintf(stderr, "here\n");
26   pthread_create(&thread2, NULL, thread_fun, NULL);
27   fprintf(stderr, "there\n");
28   pthread_join(thread1, NULL);
29   pthread_join(thread2, NULL);
30
31   fprintf(stderr, "User main is done\n");
32   return 0;
33 }