]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/tsan/mmap_stress.cc
1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
6 void *SubWorker(void *arg
) {
8 const int kMmapSize
= 65536;
9 for (int i
= 0; i
< 500; i
++) {
10 int *ptr
= (int*)mmap(0, kMmapSize
, PROT_READ
| PROT_WRITE
,
11 MAP_PRIVATE
| MAP_ANON
, -1, 0);
13 munmap(ptr
, kMmapSize
);
18 void *Worker1(void *arg
) {
21 for (int i
= 0; i
< 4; i
++)
22 pthread_create(&th
[i
], 0, SubWorker
, 0);
23 for (int i
= 0; i
< 4; i
++)
24 pthread_join(th
[i
], 0);
28 void *Worker(void *arg
) {
31 for (int i
= 0; i
< 4; i
++)
32 pthread_create(&th
[i
], 0, Worker1
, 0);
33 for (int i
= 0; i
< 4; i
++)
34 pthread_join(th
[i
], 0);
40 for (int i
= 0; i
< 4; i
++)
41 pthread_create(&th
[i
], 0, Worker
, 0);
42 for (int i
= 0; i
< 4; i
++)
43 pthread_join(th
[i
], 0);
44 fprintf(stderr
, "DONE\n");