net: Allow binding of unspecified address without address existance
[dragonfly.git] / test / sysperf / sleep900k.c
blob0bd33d9fbf8924373f97122ed2e2e56b04a1cb18
1 /*
2 * Infinite sleep test with 900,000 processes (1/10 second loop)
4 * Requires system w/ 128GB+ of ram, kern.maxproc=4000000 set in
5 * /boot/loader.conf. 60 second stabilization time after last
6 * process is forked.
8 * Also test tear-down by ^C'ing the test.
9 */
10 #include <sys/types.h>
11 #include <sys/wait.h>
12 #include <sys/mman.h>
13 #include <sys/resource.h>
14 #include <errno.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <unistd.h>
18 #include <string.h>
19 #include <signal.h>
21 #define COUNT 900000
23 int
24 main(int ac, char **av)
26 int status;
27 int i;
28 int j;
29 int idno;
30 char *path;
31 char *id;
32 char c;
34 if (ac == 1) {
35 for (i = 0; i < COUNT; i += 100) {
36 #if 0
37 asprintf(&path, "cp %s /tmp/x%06d", av[0], i);
38 system(path);
39 free(path);
40 asprintf(&path, "/tmp/x%06d", i);
41 #else
42 asprintf(&path, "%s", av[0]);
43 #endif
44 asprintf(&id, "%d", i);
45 if (vfork() == 0) {
46 execl(path, path, id, NULL);
47 _exit(0);
49 if (i % 1000 == 0) {
50 printf("running %d\r", i);
51 fflush(stdout);
53 free(path);
54 free(id);
56 } else {
57 idno = strtol(av[1], NULL, 0);
58 setpriority(PRIO_PROCESS, 0, 5);
59 for (j = 0; j < 100; ++j) {
60 if (j == 99 || fork() == 0) {
61 int dummy = 0;
63 setpriority(PRIO_PROCESS, 0, 15);
64 sleep(60);
66 while (1) {
67 umtx_sleep(&dummy, 0, 100000);
69 _exit(0);
72 while (wait3(NULL, 0, NULL) >= 0 || errno == EINTR)
74 _exit(0);
76 printf("running %d\n", i);
77 for (;;) {
78 sleep(1);
80 return 0;