6 #include "model-assert.h"
10 static thrd_t *threads;
11 static int num_threads;
13 unsigned int idx1, idx2;
21 thrd_t curr = thrd_current();
23 for (i = 0; i < num_threads; i++)
24 if (curr.priv == threads[i].priv)
30 static void main_task(void *param)
33 int pid = *((int *)param);
36 atomic_store_explicit(&x[1], 17, relaxed);
38 } else if (pid % 4 == 1) {
39 atomic_store_explicit(&x[2], 37, relaxed);
41 } else if (pid % 4 == 2) {/*
44 a = atomic_load_explicit(&x[idx1], relaxed);
50 b = atomic_load_explicit(&x[idx2], relaxed);
56 int user_main(int argc, char **argv)
60 unsigned int in_sum = 0, out_sum = 0;
62 atomic_init(&x[1], 0);
63 atomic_init(&x[2], 0);
65 stack = calloc(1, sizeof(*stack));
68 threads = malloc(num_threads * sizeof(thrd_t));
69 param = malloc(num_threads * sizeof(*param));
71 init_stack(stack, num_threads);
73 for (i = 0; i < num_threads; i++) {
75 thrd_create(&threads[i], main_task, ¶m[i]);
77 for (i = 0; i < num_threads; i++)
78 thrd_join(threads[i]);
81 //correct |= (a == 17 || a == 37 || a == 0);
82 //MODEL_ASSERT(correct);