More minor IPI work.
[dragonfly/vkernel-mp.git] / test / stress / eatmem.c
blobdc332b9f6d82e384faa8f03bcfabbd7e8ff57999
1 /*
2 * EATMEM.C
4 * (c)Copyright 2003 Matthew Dillon <dillon@backplane.com>. This code is
5 * hereby placed in the public domain.
7 * This program 'eats' memory by allocating and touching it. Make sure your
8 * datasize resource limit is sufficient for the amount of memory you specify.
10 * $DragonFly: src/test/stress/eatmem.c,v 1.1 2003/08/25 21:41:00 dillon Exp $
12 #include <sys/types.h>
13 #include <sys/mman.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
18 int
19 main(int ac, char **av)
21 int bytes;
22 int i;
23 char *ptr;
25 if (ac == 1) {
26 printf("eatmem MB [msec/page]\n");
27 printf("specifying msec/page will cause eatmem to loop forever\n");
28 exit(1);
30 bytes = strtol(av[1], NULL, 0) * 1024 * 1024;
31 ptr = malloc(bytes);
33 for (;;) {
34 for (i = 0; i < bytes; i += 4096) {
35 ++ptr[i];
36 if (av[2] && strtol(av[2], NULL, 0))
37 usleep(1000 * strtol(av[2], NULL, 0));
38 if (i == 0)
39 puts("loop0");
41 if (ac != 3)
42 break;
43 puts("loop");
45 puts("ok");
46 sleep(10);
47 puts("done");
48 exit(0);