[comp.os.os2] Using >20 files in OS/2

hjb@otter.hpl.hp.com (Harry Barman) (11/20/89)

Hi,

I've just stumbled over a problem with having too many open files,  and was
wondering if anyone knows any good workarounds.

The problem....

We are porting a Unix program to OS/2 1.1.  We started off using the C library,
but hit up against the 20 file limit.  I can't find anything in the
documentation that says how to increase it, is such a thing possible???

For many of the files,  we can use DosOpen, and DosSetMaxFH to allocate more
file handles.   But... we still want to use fscanf and friends for some of the
files.  The trouble is that the Dos file calls don't seem to coexist with the
C library file calls.  I expected that if the bulk of the files use the Dos
calls,  the C library would then have a lot more file descriptors available,
but this is not to be.  There seems to be some interaction between the two.
I also tried opening some C file descriptors (by dup'ing stdin) before doing
the Dos opens,  but didn't have the desired effect, PAH!

OK... so does anyone have another version of the C lib floating around, or
does anyone know how to convince the C library and dos file calls to work
with each other?

Cheers,

Harry

slh@fred.cs.washington.edu (Scott Heyano) (11/21/89)

	I don't have a reference with me right now, but isn't there a line you
can put in your config.sys or autoexec to set the open file limit
(BUFFERS, maybe?).

hjb@otter.hpl.hp.com (Harry Barman) (11/21/89)

It turns out that it is possible to increase the number of open files
supported by the C library.  It isn't documented in the printed documentation,
but there is some info about it in one of the README files.

-- Harry

lbruck@eng.umd.edu (Lewis Bruck) (11/21/89)

The way I was able to get around this problem was to dig through the
microsoft startup code (ughh...) until I found a variable called _nfile.
To increase the number of file handles, call DosSetMaxFH and assign
a higher number to _nfile (remember to declare it as extern to keep the
linker happy).  It important to remember that simply calling DosSetMaxFH()
does not give you all the requested file handles (i.e. if the rest of the
system is using 100 filehandles, then you would only be able to use about
155 filehandles in the process).  Compare the 255 file handle maximum in 1.1
to the 100,000 in Netware 386...

Lewis Bruck
not officially representing anyone...

cs169054@brunix (Peter Golde) (11/21/89)

In article <14570001@otter.hpl.hp.com> hjb@otter.hpl.hp.com (Harry Barman) writes:
>We are porting a Unix program to OS/2 1.1.  We started off using the C library,
>but hit up against the 20 file limit.  I can't find anything in the
>documentation that says how to increase it, is such a thing possible???

This is from memory, but I believe the MS C 5.1 startup code had commented
out code for increasing the file handle limit.  I believe you should look	in os2\crt0.asm or os2\crt0dat.asm.  Hope this helps.

shap@bunker.UUCP (Joseph D. Shapiro) (11/22/89)

In article <14570001@otter.hpl.hp.com> hjb@otter.hpl.hp.com (Harry Barman) writes:
>We are porting a Unix program to OS/2 1.1.  We started off using the C library,
>but hit up against the 20 file limit.  I can't find anything in the
>documentation that says how to increase it, is such a thing possible???
>
>For many of the files,  we can use DosOpen, and DosSetMaxFH to allocate more
>file handles.   But... we still want to use fscanf and friends for some of the
>files.  The trouble is that the Dos file calls don't seem to coexist with the
.
.
.


There is an
	extern int near _nfiles;

which you can set to the new value specified through DosSetMaxFH.

Another solution is to modify to startup file CRT0DAT.ASM, uncommenting
a few lines which are there just to do the DosSetMaxFH and set _nfiles.
It uses a defile called NFILE, which you may have to modify in stdio.h.

-- 
__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__
Joe Shapiro					"My other car is a turbo...
ISC-Bunker Ramo     				 ...too."
{decvax,yale,philabs,oliveb}!bunker!shap