6 #include "model-assert.h"
10 static thrd_t *threads;
11 static unsigned int *input;
12 static unsigned int *output;
13 static int num_threads;
17 thrd_t curr = thrd_current();
19 for (i = 0; i < num_threads; i++)
20 if (curr.priv == threads[i].priv)
27 unsigned int output1, output2;
29 static void main_task(void *param)
31 int pid = *((int *)param);
34 succ1 = dequeue(queue, &output1);
36 printf("Thrd 1: Dequeue %d.\n", output1);
38 printf("Thrd 1: Dequeue NULL.\n");
39 } else if (pid % 4 == 1) {
44 int user_main(int argc, char **argv)
50 unsigned int in_sum = 0, out_sum = 0;
52 queue = calloc(1, sizeof(*queue));
55 threads = malloc(num_threads * sizeof(thrd_t));
56 param = malloc(num_threads * sizeof(*param));
57 input = calloc(num_threads, sizeof(*input));
58 output = calloc(num_threads, sizeof(*output));
60 init_queue(queue, num_threads);
61 for (i = 0; i < num_threads; i++) {
63 thrd_create(&threads[i], main_task, ¶m[i]);
65 for (i = 0; i < num_threads; i++)
66 thrd_join(threads[i]);