The CDSSpec checker's benchmarks
[model-checker-benchmarks.git] / concurrent-hashmap / testcase2.cc
1 #include <threads.h>
2 #include "hashmap.h"
3
4 HashMap *table;
5
6 /** Making w4 & w11 seq_cst */
7
8 int k1 = 1;
9 int k2 = 3;
10 int v1 = 10;
11 int v2 = 30;
12
13 void threadA(void *arg) {
14         int r1 = put(table, k1, v1);
15         int r2 = get(table, k2);
16     printf("r2=%d\n", r2);
17 }
18
19 void threadB(void *arg) {
20         int r3 = put(table, k2, v2);
21         int r4 = get(table, k1);
22     printf("r4=%d\n", r4);
23 }
24
25 int user_main(int argc, char *argv[]) {
26         
27         thrd_t t1, t2;
28         /** @Entry */
29         table = new HashMap;
30
31         thrd_create(&t1, threadA, NULL);
32         thrd_create(&t2, threadB, NULL);
33         thrd_join(t1);
34         thrd_join(t2);
35         
36         return 0;
37 }
38
39