Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / test / testcases / mem / mmap_1 / mmap_1.c
1 /* Testcase for issue1343 */
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <pthread.h>
5 #include <sys/types.h>
6 #include <dirent.h>
7 #include <errno.h>
8 #include <unistd.h>
9
10
11
12 void* tester(void *arg)
13 {
14         sleep(2);
15 }
16
17 int main(int argc, char *argv[])
18 {
19         int i, ret, nthreads;
20         pthread_t th;
21         pthread_t *threads;
22
23         if (argc <= 1)
24         {
25                 printf("Need one argument\n");
26                 exit(1);
27         }
28
29         nthreads = atoi(argv[1]);
30         threads = malloc(nthreads * sizeof(pthread_t));
31         if (threads == NULL)
32                 return 2;
33
34         printf("Trying with %d threads\n", nthreads);
35
36         printf("Creating tester threads\n");
37         for (i = 0; i < nthreads; i++)
38                 pthread_create(&threads[i], NULL, tester, NULL);
39
40         sleep(5);
41
42         printf("Starting join procedure...\n");
43         for (i = 0; i < nthreads; i++)
44                 pthread_join(threads[i], NULL);
45
46         printf("Done!\n");
47         return 0;
48 }