🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #312

Re: Files per process question

#312
From: Ralf Brown
Date: Sat, 08 Aug 1992 03:44
72 lines
4283 bytes
If this isn't already in the FAQ, it probably should be.  I've answered
this question several times in the past....

In article <l85rgvINN8us@levelland.cs.utexas.edu> phil@cs.utexas.edu (Philip Smolen) writes:
}In article <1992Aug6.224812.455@ccsvax.sfasu.edu> z_harbergt@ccsvax.sfasu.edu writes:
}>In article <92218.074922MKK2@psuvm.psu.edu>, <MKK2@psuvm.psu.edu> writes:
}>>   Q:  Is there a limit to the number of files that a program can open?
}>>       Is there someway to increase that limit?  Can you tell me where
}>>       I can learn more about this vaguely asked question? 8-)
}>
}>  " DOS allows only 20 files open for any one application, and takes
}>  5 of these for its own use."
}
}Does DOS really limit the open files to 20?
}
}I recently loaded the Oberon system which runs on top of DOS.
}The installation instructions tell you to set FILES=64 in your
}config.sys.  I did this and DOS did not complain.  I was using

There are three separate and mostly independent limits on the number of
open files.

1. There is a system-wide limit on the number of open files, set with the
	CONFIG.SYS option FILES=.  This is the total number of files which
	may be opened by all programs and TSRs currently loaded.  The first
	three FILES= entries are used up for the five standard file handles
	which, unless redirected, reference CON (stdin,stdout,stderr), AUX
	(stdaux), and PRN (stdprn).  If FILES=50, Process A can open 15 new
	files, then Process B can open another 15 files, and Process C can
	open another 15 files, but process D will only be able to open two
	files.

2. There is a per-process limit on the number of open files, which defaults
	to 20 per process, but can be changed with a function call in DOS
	3.3 and up, and can be bypassed in various sneaky ways in earlier
	versions.  The limit can only be reached if there are sufficient
	FILES= entries still unused.

3. The library functions you use may limit the number of open files.  For
	example, the C stdio functions need to know whether the file was
	opened in text or binary mode, for read/write/append, etc.  Both
	Borland C and MS C use an array with default size 20.  Thus even
	if limits 1 and 2 are both greater than 20, you may not be able to
	open more than 20 files without recompiling one of the library
	modules (the one defining the file information array).

Exceeding the 20-file per-process limit:  Assuming that FILES= is large
enough and the library functions do not limit the number of open files,
it is possible to open more than 20 files for DOS 2.0 and higher, using
one of three methods.
	a. INT 21h/AH=67h in DOS 3.3 and higher allows you to request an
	   increase in the per-process file limit.  Due to a bug in the
	   original release of DOS 3.30, the requested limit in BX should
	   always be *odd*.
	b. For DOS 3.0 and up, there is a pointer in the PSP to the table
	   which stores file information for the program, as well as a word
	   containing the length of the table.  The file limit can be raised
	   by allocating a new table, copying the old table into the new one,
	   filling the remainder of the new table with FFh, and adjusting
	   the PSP pointer and limit word.
	c. For DOS 2.0 and up, you can write a set of file access functions
	   which patch in the appropriate value into a fixed location in the
	   PSP file information table (the table itself is not movable in DOS
	   2.x).



-- 
Internet: RALF+@CS.CMU.EDU   |The University would disclaim this if it knew...
FIDO: Ralf Brown 1:129/26.1  |"Whenever things sound easy, it turns out
BIT: RALF%CS.CMU.EDU@CARNEGIE| there's one part you didn't hear."
AT&Tnet: (412)268-3053 school|		-- Donald E. Westlake, _Drowned_Hopes_
Technical Details
Message-ID: <1992Aug08.034430.58872@cs.cmu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!rochester!cantaloupe.srv.cs.cmu.edu!ralf
References: <92218.074922MKK2@psuvm.psu.edu> <1992Aug6.224812.455@ccsvax.sfasu.edu> <l85rgvINN8us@levelland.cs.utexas.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!rochester!cantaloupe.srv.cs.cmu.edu!ralf
From: ralf+@cs.cmu.edu (Ralf Brown)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Files per process question
Message-ID: <1992Aug08.034430.58872@cs.cmu.edu>
Date: 8 Aug 92 03:44:30 GMT
References: <92218.074922MKK2@psuvm.psu.edu> <1992Aug6.224812.455@ccsvax.sfasu.edu> <l85rgvINN8us@levelland.cs.utexas.edu>
Organization: School of Computer Science, Carnegie Mellon
Lines: 72
Nntp-Posting-Host: b.gp.cs.cmu.edu