pps_fetch: introduce a helper to handle timeouts
[dragonfly.git] / test / stress / t_mlockall.c
blob90ff41fdec3915c3caa324b5f0ff9bc47b41d5fe
1 #include <err.h>
2 #include <stdlib.h>
3 #include <sys/mman.h>
4 #include <sys/types.h>
5 #include <sys/wait.h>
6 #include <unistd.h>
8 #define TESTSIZE (32*1024*1024L)
10 char *TestBuf;
12 void
13 child(void)
15 size_t i;
17 sleep(1);
18 for (i = 0; i < TESTSIZE; i += 4096) {
19 ++TestBuf[i];
20 //usleep(1000000 / 10);
22 usleep(1000000 / 4); /* ensure children are concurrent */
25 int
26 main(int argc, char **argv)
28 int status;
30 TestBuf = malloc(TESTSIZE);
32 if (fork() == 0) {
33 if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1)
34 err(1, "mlockall(MCL_CURRENT | MCL_FUTURE)");
35 fork();
36 child();
37 exit(0);
39 wait(&status);
41 return (0);