Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / functionalities / tsan / thread_numbers / main.c
blobaf0b7a2678982d1888b4cbb427b0a252024bdcbe
1 #include <pthread.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
6 char *pointer;
8 void *nothing(void *p) {
9 return NULL;
12 void *f1(void *p) {
13 pointer[0] = 'x';
14 sleep(100);
15 return NULL;
18 void *f2(void *p) {
19 pointer[0] = 'y';
20 sleep(100);
21 return NULL;
24 int main (int argc, char const *argv[])
26 pointer = (char *)malloc(10);
28 for (int i = 0; i < 3; i++) {
29 pthread_t t;
30 pthread_create(&t, NULL, nothing, NULL);
31 pthread_join(t, NULL);
34 pthread_t t1;
35 pthread_create(&t1, NULL, f1, NULL);
37 for (int i = 0; i < 3; i++) {
38 pthread_t t;
39 pthread_create(&t, NULL, nothing, NULL);
40 pthread_join(t, NULL);
43 pthread_t t2;
44 pthread_create(&t2, NULL, f2, NULL);
46 pthread_join(t1, NULL);
47 pthread_join(t2, NULL);
49 return 0;