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; 7 8 void thread_func() { 9 pseudo_barrier_wait(g_barrier); 10 printf("%s starting...\n", __FUNCTION__); 11 for (uint32_t i = 0; i < 10; ++i) 12 g_val = i; 13 } 14 15 int main(int argc, char const *argv[]) { 16 printf("Before running the thread\n"); 17 pseudo_barrier_init(g_barrier, 2); 18 std::thread thread(thread_func); 19 20 printf("After running the thread\n"); 21 pseudo_barrier_wait(g_barrier); 22 23 thread.join(); 24 25 return 0; 26 } 27