4 #include "libthreads.h"
8 static void a(atomic_int *obj)
14 printf("load 32 yields: %d\n", load_32(&i));
16 for (i = 0; i < 2; i++) {
17 printf("Thread %d, loop %d\n", thrd_current(), i);
20 ret = atomic_load(obj);
21 printf("Read value: %d\n", ret);
24 atomic_store(obj, i + 1);
25 printf("Write value: %d\n", i + 1);
36 obj = malloc(sizeof(*obj));
40 printf("Thread %d: creating 2 threads\n", thrd_current());
41 thrd_create(&t1, (thrd_start_t)&a, obj);
42 thrd_create(&t2, (thrd_start_t)&a, obj);
47 printf("Thread %d is finished\n", thrd_current());