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