From: Thomas D. D. <to...@sp...> - 2003-11-17 17:38:55
|
I took a quick look at baseaddr() in src/frontend/resource.c. # uname -a FreeBSD asus 4.8-STABLE FreeBSD 4.8-STABLE #1: Wed Aug 13 07:00:06 PDT 2003 \ root@asus:/usr/obj/usr/src/sys/ASUS i386 getrlimit() and getrusage() should provide a solution. Below is a diff for src/frontend/resource.c. This could be done better. Maybe use HAVE_GETRUSAGE?? I think most modern systems have good vm management. From man sbrk, The brk() and sbrk() functions are legacy interfaces from before the advent of modern virtual memory management. Maybe baseaddr() and init_rlimits() could be removed and ft_ckspace() could be written to just use getrlimit()? and getrusage()? baseaddr() is only used in resource.c and then only within init_rlimits(). So, if init_rlimits() is removed, the only change outside resource.c is in src/main.c. I no longer have access to systems other than FreeBSD. tomdean 30,31d29 < < 35a34 > # ifndef HAVE_GETRLIMIT 37a37 > endif 101c101,107 < getrlimit(RLIMIT_DATA, &rld); --- > struct rusage ruse; > long ticks, cur_use; > getrlimit(RLIMIT_DATA, &rld); /* get current limit */ > getrusage(0, &ruse); /* get resource usage */ > ticks=sysconf(_SC_CLK_TCK); /* for conversion to K bytes */ > usage=1024*ruse.ru_idrss/ticks; /* usage is in bytes */ > 104c110 < limit = rld.rlim_cur - (enddata - startdata); /* rlim_max not used */ --- > limit = rld.rlim_cur - usage; /* rlim_max not used */ 110,111d115 < < # endif 113a118,119 > > # endif |