Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* dlopen limits
@ 1995-11-17  5:00 Marinos Yannikos
  1995-11-21  5:00 ` David Metsky
  1995-11-21  5:00 `  Steven Winikoff 
  0 siblings, 2 replies; 3+ messages in thread
From: Marinos Yannikos @ 1995-11-17  5:00 UTC (permalink / raw)


I noticed that it is not possible to dlopen() more than 95 shared libraries
at the same time under Digital Unix 3.2a. Is this an arbitrary limit, or 
is there some other reason, like efficiency problems, for this? Appended 
below is a program that shows the problem (it will fill up your current
directory with func_*.{c,o,so} files).

Thanks,
-nino

PS. If you can get this to work with more than 95 functions on 3.2c or better,
please let me know!
--- 8< ---
#include <stdio.h>
#include <dlfcn.h>

#define N 200
void *h[N];
int (*func[N])();
main()
{
	FILE *f;
	int i;
	char s[100];
	for (i=0; i<N; i++)
	{
		fprintf(stderr, "Function %d\r",i);
		sprintf(s,"func_%d.c",i);
		f=fopen(s,"w");
		fprintf (f,"func_%d(){return 1+%d;}",i,i);
		fclose(f);
		sprintf(s,"cc -c func_%d.c; ld -shared func_%d.o -o func_%d.so -lc",i,i,i);
		system(s);
		sprintf(s,"func_%d.so",i);
		h[i]=dlopen(s, RTLD_LAZY);
		if (h[i]==NULL) {fprintf(stderr, "\nError: %s\n", dlerror()); exit(1);}
		sprintf(s,"func_%d",i);
		func[i]=dlsym(h[i],s);
	}
	for (i=0; i<N; i++)
	{
		fprintf (stderr, "Testing %d\r",i);
		if (func[i]() != 1+i)
			fprintf (stderr, "\nError in function %d!\n",i);
	}
}
--- >8 ---
-- 
http://www.complang.tuwien.ac.at/nino




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dlopen limits
  1995-11-17  5:00 dlopen limits Marinos Yannikos
@ 1995-11-21  5:00 ` David Metsky
  1995-11-21  5:00 `  Steven Winikoff 
  1 sibling, 0 replies; 3+ messages in thread
From: David Metsky @ 1995-11-21  5:00 UTC (permalink / raw)



From the engineer responsible for the loader:


The limit of roughly 95 shared libraries loaded either
as static dependencies or by dlopen is imposed by the
kernel configuration parameter for the maximum number
of mmap entries allowed per process.  This is set to
200 by default.  Each shared library requires at least 2
mmap entries (3 if it's bss size isn't zero -- use
"odump -ov" to identify the bss size.)  The program,
loader, heap and stack take up another 10-12 mmap entries.

As a rule of thumb, I'd use the formula

    mapentries = 20 + ( max-libraries * 3 )

To increase the maximum number of shared libraries that
a process can load simply reconfigure the kernel's
mapentries limit.  The following instructions will work on
DEC OSF/1 V3.2 and up.

To examine the current setting for the mapentries limit:

% /sbin/sysconfig -q vm vm-mapentries
vm-mapentries = 200

To change the mapentries limit to 1000:

1. edit /etc/sysconfigtab and add the following 2 lines

vm:
	vm-mapentries = 1000

2. reboot the system


-- 
David Metsky	Digital UNIX Software Group      metsky@zk3.dec.com
-- 
David Metsky	Digital UNIX Software Group      metsky@zk3.dec.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dlopen limits
  1995-11-17  5:00 dlopen limits Marinos Yannikos
  1995-11-21  5:00 ` David Metsky
@ 1995-11-21  5:00 `  Steven Winikoff 
  1 sibling, 0 replies; 3+ messages in thread
From:  Steven Winikoff  @ 1995-11-21  5:00 UTC (permalink / raw)


In <48i16o$b9t@news.tuwien.ac.at>
nino@complang.tuwien.ac.at (Marinos Yannikos) writes:

>PS. If you can get this to work with more than 95 functions on 3.2c or better,
>please let me know!

Just for fun I tried running your program on our 2100 5/250 under 3.2c,
and it failed after 95 functions just as you report for 3.2a.

I'm sorry to bring you the bad news. :-(

     - Steven
________________________________________________________________________
Steven Winikoff      |       smw@         | "I don't want to run the
Software Analyst     | alcor.concordia.ca | world; I merely want to own
Computing Services   |                    | a substantial portion of the
Concordia University | (514) 848-7619     | preferred stock" - Alan Dean
Montreal, QC, Canada | (10:00-18:00 EST)  | Foster,  Cat-A-Lyst



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1995-11-21  5:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-11-17  5:00 dlopen limits Marinos Yannikos
1995-11-21  5:00 ` David Metsky
1995-11-21  5:00 `  Steven Winikoff 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox