malloc: add myMalloc() and myFree()
[c11tester.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", thread_current()->id, i);
12                 if (i % 2)
13                         atomic_load(obj);
14         }
15 }
16
17 void user_main()
18 {
19         struct thread t1, t2;
20         atomic_int obj;
21
22         printf("%s() creating 2 threads\n", __func__);
23         thread_create(&t1, (void (*)())&a, &obj);
24         thread_create(&t2, (void (*)())&a, &obj);
25
26         thread_join(&t1);
27         thread_join(&t2);
28         printf("%s() is finished\n", __func__);
29 }