userprog: use typedef'd thrd_start_t
[model-checker.git] / userprog.c
1 #include <stdio.h>
2
3 #include "libthreads.h"
4 #include "libatomic.h"
5
6 static void a(atomic_int *obj)
7 {
8         int i;
9
10         for (i = 0; i < 10; i++) {
11                 printf("Thread %d, loop %d\n", thrd_current(), i);
12                 switch (i % 4) {
13                 case 1:
14                         atomic_load(obj);
15                         break;
16                 case 3:
17                         atomic_store(obj, i);
18                         break;
19                 }
20         }
21 }
22
23 void user_main()
24 {
25         thrd_t t1, t2;
26         atomic_int obj;
27
28         printf("Creating 2 threads\n");
29         thrd_create(&t1, (thrd_start_t)&a, &obj);
30         thrd_create(&t2, (thrd_start_t)&a, &obj);
31
32         thrd_join(t1);
33         thrd_join(t2);
34         printf("Thread is finished\n");
35 }