1 | #include "pseudo_barrier.h" |
---|---|
2 | #include <cstdio> |
3 | #include <thread> |
4 | |
5 | volatile uint32_t g_val = 0; |
6 | pseudo_barrier_t g_barrier, g_barrier2; |
7 | |
8 | void thread_func() { |
9 | pseudo_barrier_wait(g_barrier); |
10 | pseudo_barrier_wait(g_barrier2); |
11 | printf(format: "%s starting...\n", __FUNCTION__); |
12 | for (uint32_t i = 0; i < 10; ++i) |
13 | g_val = i; |
14 | } |
15 | |
16 | int main(int argc, char const *argv[]) { |
17 | printf(format: "Before running the thread\n"); |
18 | pseudo_barrier_init(g_barrier, 2); |
19 | pseudo_barrier_init(g_barrier2, 2); |
20 | std::thread thread(thread_func); |
21 | |
22 | printf(format: "After launching the thread\n"); |
23 | pseudo_barrier_wait(g_barrier); |
24 | |
25 | printf(format: "After running the thread\n"); |
26 | pseudo_barrier_wait(g_barrier2); |
27 | |
28 | thread.join(); |
29 | |
30 | return 0; |
31 | } |
32 |