Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make sthread_inside_simgrid static into libsthread in the (vain) hope that it'll...
[simgrid.git] / examples / sthread / sthread-mutex-simple.c
1 /* Simple test code with no bug  */
2
3 #include "src/sthread/sthread.h"
4 #include <stdio.h>
5
6 sthread_mutex_t mutex;
7
8 static void* thread1_fun(void* ignore)
9 {
10   sthread_mutex_lock(&mutex);
11   sthread_mutex_unlock(&mutex);
12
13   return NULL;
14 }
15 static void* thread2_fun(void* ignore)
16 {
17   sthread_mutex_lock(&mutex);
18   sthread_mutex_unlock(&mutex);
19
20   return NULL;
21 }
22
23 int main(int argc, char* argv[])
24 {
25   sthread_mutex_init(&mutex, NULL);
26
27   sthread_t thread1, thread2;
28   sthread_create(&thread1, NULL, thread1_fun, NULL);
29   sthread_create(&thread2, NULL, thread2_fun, NULL);
30   // pthread_join(thread1, NULL);
31   // pthread_join(thread2, NULL);
32   fprintf(stderr, "done\n");
33
34   return 0;
35 }