--------------7AF96ACF6C0232DD18BDB3BD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
The new Linux Version (2.0.0/2.0.29) no not honor the specific
stack/memory limits. Instead there is RLIMIT_AS (address space),
that seems currently not to be supported by tcsh/bash so you cannot
easily set it.
Every memory allocation is checked against RLIMIT_AS so there will
be no difference between stack mem/heap mem/static mem. Don't know
if this is OK.
You may check things with the program attached.
Grettings
Stefan
--
mailto:Stefan.Vogtner@rz.ruhr-uni-bochum.de ****
http://unibo6.theochem.ruhr-uni-bochum.de/stvo ****
****
--------------7AF96ACF6C0232DD18BDB3BD
Content-Type: text/plain; charset=us-ascii; name="Makefile"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Makefile"
CC=gcc -ansi -Wall -pedantic
CFLAGS=-O2
rcheck: rcheck.o rlimits.o getrus_.o set_as.o
--------------7AF96ACF6C0232DD18BDB3BD
Content-Type: text/plain; charset=us-ascii; name="getrus_.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="getrus_.c"
/*
*
* getrus_.c -- get resource usage
*
* 1997-06-10 stvo
*
* Stefan Vogtner
*
*/
#include <sys/resource.h>
#include <stdio.h>
void getrus(void)
{
struct rusage self;
if (getrusage(RUSAGE_SELF,&self) == -1) {
perror("@getrus: getrusage(RUSAGE_SELF) failed");
}
printf(
" user time used : %ld.%6.6ld s\n"
" system time used : %ld.%6.6ld s\n"
" maximum resident set size : %ld\n"
" integral shared memory size : %ld\n"
" integral unshared data size : %ld\n"
"integral unshared stack size : %ld\n"
" page reclaims : %ld\n"
" page faults : %ld\n"
" swaps : %ld\n"
" block input operations : %ld\n"
" block output operations : %ld\n"
" messages sent : %ld\n"
" messages received : %ld\n"
" signals received : %ld\n"
" voluntary context switches : %ld\n"
" involuntary : %ld\n",
self.ru_utime.tv_sec*1, self.ru_utime.tv_usec,
self.ru_stime.tv_sec*1, self.ru_stime.tv_usec,
self.ru_maxrss,
self.ru_ixrss,
self.ru_idrss,
self.ru_isrss,
self.ru_minflt,
self.ru_majflt,
self.ru_nswap,
self.ru_inblock,
self.ru_oublock,
self.ru_msgsnd,
self.ru_msgrcv,
self.ru_nsignals,
self.ru_nvcsw,
self.ru_nivcsw);
}
--------------7AF96ACF6C0232DD18BDB3BD
Content-Type: text/plain; charset=us-ascii; name="rcheck.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="rcheck.c"
/*
*
* rlim.c -- check the resource limits
*
* 1997-05-10 stvo
*
* Stefan Vogtner
*
*/
#include <stdio.h>
#include <stdlib.h>
void show_limits (void);
void getrus (void);
void set_as (long);
volatile void trash (volatile char *p, int len)
{
volatile char *q = p;
int len2 = len;
/* write */
do
*p++ = 42;
while (--len);
/* read */
do
(void) *q++;
while (--len2);
}
int main (int argc, char **argv)
{
volatile char *p;
int i;
set_as (1024L*1024L);
show_limits ();
i = argv[1] ? atoi(argv[1]) : 1;
printf ("mallocing %d bytes\n", i);
p = malloc (i);
if (!p)
perror ("malloc failed"), exit (-1);
printf ("write/read %d bytes\n", i);
trash (p, i);
getrus ();
return 0;
}
--------------7AF96ACF6C0232DD18BDB3BD
Content-Type: text/plain; charset=us-ascii; name="rlimits.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="rlimits.c"
/*
*
* rlimits.c -- display resource limits
*
* 1997-06-10 stvo
*
* Stefan Vogtner
*
*/
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <stdio.h>
#define PRIL(RL) \
do { \
struct rlimit rlim; \
\
getrlimit (RL, &rlim); \
printf ("%14.14s: %12ld %12ld\n", \
#RL, rlim.rlim_cur, rlim.rlim_max); \
} while (0)
void show_limits (void)
{
printf ("\n%14.14s: %12.12s %12.12s\n",
"Limit", "current", "max");
#ifdef RLIMIT_DATA
PRIL (RLIMIT_DATA);
#endif
#ifdef RLIMIT_STACK
PRIL (RLIMIT_STACK);
#endif
#ifdef RLIMIT_CORE
PRIL (RLIMIT_CORE);
#endif
#ifdef RLIMIT_RSS
PRIL (RLIMIT_RSS);
#endif
#ifdef RLIMIT_MEMLOCK
PRIL (RLIMIT_MEMLOCK);
#endif
#ifdef RLIMIT_AS
PRIL (RLIMIT_AS);
#endif
}
--------------7AF96ACF6C0232DD18BDB3BD
Content-Type: text/plain; charset=us-ascii; name="set_as.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="set_as.c"
/*
*
* set_as.c -- set address space
*
* 1997-06-10 stvo
*
* Stefan Vogtner
*
*/
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <stdio.h>
void set_as (long size)
{
#ifdef RLIMIT_AS
struct rlimit rlim;
int rc;
rlim.rlim_cur = size;
rc = setrlimit (RLIMIT_AS, &rlim);
if (rc)
perror ("could not set RLIMIT_AS"), exit (-1);
#else
printf ("no RLIMIT_AS defined in this OS version\n");
#endif
}
--------------7AF96ACF6C0232DD18BDB3BD--