4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include <sys/types.h>
39 * This file tests for swap space exhaustion
41 * cc -O -o exhaust exhaust.c -lmtmalloc
44 void * be_thread(void *);
47 main(int argc
, char ** argv
)
55 ncpus
= sysconf(_SC_NPROCESSORS_CONF
);
57 fd
= open("/dev/zero", O_RDONLY
);
65 stacks
[ncpus
] = mmap(0, 1<<23, PROT_READ
|PROT_WRITE
,
70 mallocctl(MTCHUNKSIZE
, 150);
72 ncpus
= sysconf(_SC_NPROCESSORS_CONF
);
74 thr_create(stacks
[ncpus
], 1<<23, be_thread
, NULL
, THR_BOUND
,
77 while (thr_join(NULL
, NULL
, NULL
) == 0);
89 printf("why am I here\n");
93 if ((p
= malloc(rand())) == NULL
) {
95 fprintf(stderr
, "Errno is %d\n", errno
);
99 printf("free %p\n", p
);