This source file includes following definitions.
- thr1_run
- thr2_run
- main
1
2
3
4
5
6
7
8
9
10
11
12 #include "opal_config.h"
13
14 #include <stdio.h>
15
16 #include "support.h"
17 #include "opal/constants.h"
18 #include "opal/threads/threads.h"
19 #include "opal/sys/atomic.h"
20
21
22
23
24 static opal_atomic_int_t count = 0;
25
26
27 static void* thr1_run(opal_object_t* obj)
28 {
29 opal_atomic_add (&count, 1);
30 return NULL;
31 }
32
33 static void* thr2_run(opal_object_t* obj)
34 {
35 opal_atomic_add (&count, 2);
36 return NULL;
37 }
38
39 int main(int argc, char** argv)
40 {
41 int rc;
42 opal_thread_t thr1;
43 opal_thread_t thr2;
44
45 test_init("opal_thread_t");
46
47 OBJ_CONSTRUCT(&thr1, opal_thread_t);
48 OBJ_CONSTRUCT(&thr2, opal_thread_t);
49
50 thr1.t_run = thr1_run;
51 thr2.t_run = thr2_run;
52
53 rc = opal_thread_start(&thr1);
54 test_verify_int(OPAL_SUCCESS, rc);
55
56 rc = opal_thread_start(&thr2);
57 test_verify_int(OPAL_SUCCESS, rc);
58
59 rc = opal_thread_join(&thr1, NULL);
60 test_verify_int(OPAL_SUCCESS, rc);
61
62 rc = opal_thread_join(&thr2, NULL);
63 test_verify_int(OPAL_SUCCESS, rc);
64
65 test_verify_int(3, count);
66 return test_finalize();
67 }