xref: /llvm-project/lldb/test/API/commands/trace/intelpt-multi-core-trace/multi_thread.cpp (revision a19fcc2bec81989f90700cfc63b89a0dfd330197)
1 #include <thread>
2 #include <cstring>
3 #include <unistd.h>
4 using namespace std;
5 
6 bool done = false;
foo()7 void foo() {
8   int x = 0;
9   for (int i = 0; i < 10000; i++)
10     x++;
11   sleep(1);
12   for (int i = 0; i < 10000; i++)
13     x++;
14   done = true;
15 }
16 
bar()17 void bar() {
18   int y = 0;
19   while (!done) {
20     y++;
21   }
22   printf("bar %d\n", y);
23 }
24 
main()25 int main() {
26   std::thread first(foo);
27   std::thread second(bar);
28   first.join();
29   second.join();
30 
31   printf("complete\n");
32   return 0;
33 
34 }
35