[comp.sys.ibm.pc] Opening up to 255 files in DOS 3.30

chu2_ltd@uhura.cc.rochester.edu (Jim Huang) (06/28/89)

	I would like to know how to open a large number of files at
	once under MS-DOS 3.30.  For instance, if I want to open
	50 files, I would put the line:

			files = 50

	in my CONFIG.SYS file and reboot.  However, this does not 
	seem to work.

	I have heard that there are some memory-resident programs
	that allow me to do this, but I would like another way
	of doing this, e.g. a patch to COMMAND.COM, etc.

	If you have any information, source code (C and/or assembly)
	or anything else you might think is useful, could you please
	e-mail it to me?  Thank you very much.

	Jim Huang
	chu2_ltd@uhura.cc.rochester.edu  (128.151.224.17)
	University of Rochester

maa@nbires.nbi.com (Mark Armbrust) (06/29/89)

In article <2385@ur-cc.UUCP> chu2_ltd@uhura.cc.rochester.edu (Jim Huang) writes:
>
>	I would like to know how to open a large number of files at
>	once under MS-DOS 3.30.  For instance, if I want to open
>	50 files, I would put the line:
>
>			files = 50
>
>	in my CONFIG.SYS file and reboot.  However, this does not 
>	seem to work.

There is normally a 20 file per process limit in MS-DOS.  Starting with 3.30,
there is a new DOS call to increase this number.   This is from the 3.30
programmer's reference that came in our OEM kit:

===============================================

Set Handle Count (Function 67H)

 Call:

 AH = 67H
 BX
  Number of allowed handles

 Return:

 Carry set:
 AX   [error occured; return values not documented.  Probably the same as
       Allocate memory call. --maa]
 Carry not set:
  No error 



Comments:

Function 67H increases or decreases the number of files a program can
have open at one time. The maximum number of files handles is 64K. If
less than 20 are specified, the minimum handle number, 20, is assumed. If
this call is used to reduce the number of allowed handles, the new limit
does not take affect until any handles above the new limit are closed.

The user should use Call 4AH (Set Block) to allocate memory for the
extended handle list if BX is greater than 255. The maximum number for
the value of the config.sys command files is 255.

===============================================

You should be able to issue this call from C using the "intdos()" function, 
but I don't know it the C runtime library can handle more than 20 open high-
level (buffered) files.  It should not care about the number of open low-level
files since this appears to be an MS-DOS handle based I/O system.  All of this
paragraph is just my best guess.

-- 

Mark Armbrust
maa@nbires.nbi.com
maa@nbires.UUCP

dold@mitisft.Convergent.COM (Clarence Dold) (06/29/89)

in article <2385@ur-cc.UUCP>, chu2_ltd@uhura.cc.rochester.edu (Jim Huang) says:

> 	I would like to know how to open a large number of files at
> 	once under MS-DOS 3.30.  For instance, if I want to open
> 	50 files, I would put the line:

> 			files = 50

> 	in my CONFIG.SYS file and reboot.  However, this does not 
> 	seem to work.

You might be encountering a compiler limitation.
Microsoft QuickC won't open() files beyond the limit declared in stdio.h,
even though that should have no effect unless you are trying to fopen().

Even though this isn't cross-posted, a bug has surfaced in SysV 3.0
fopen() carries it's own table of available streams.
streams is generated at NFILE 20.
The per-user limit NOFILES can be set as high as 100.
if open(2) is used to open files, and fopen(3) is used to open a stream,
there is a potential situation where the file descriptor will be
higher than 20.  Streams operations WILL break.  In strange ways.
SysV 3.2 sets NFILE 60 for stdio, but the possibility still exists.

I would suggest not going to a files value higher than NFILES.
-- 
---
Clarence A Dold - dold@tsmiti.Convergent.COM		(408) 434-5293
		...pyramid!ctnews!tsmiti!dold
		P.O.Box 6685, San Jose, CA 95150-6685	MS#10-007

news@crdgw1.crd.ge.com (USENET News System) (06/29/89)

last time I looked).  DOS maintains a common table in low memory known as
the system file table (SFT).  The size of this table is set by the files=
config.sys entry.  The handle table (aka Job File Table) contains one byte
entries that index the SFT;  these values are known as the system file numbers
SFT.  There is one SFT entry for each distinct file,  ie if a file is opened
more than once there is still only one SFT entry.  (MS-DOS keeps a reference
count and owner in the SFT to sort things out).  Since the SFN is 8 bits,
there can be no more than 255 entries in the SFT.  One can make the JFT
bigger than 255,  but this action dosen't buy you anything.
From: dixon@sagittarius.crd.ge.com (walt dixon)
Path: sagittarius!dixon


Walt Dixon		{arpa:		dixon@crd.ge.com	}
			{us mail:	ge crd			}
			{		po box 8		}
			{		schenectady,  ny 12345	}
			{phone:		518-387-5798		}

Walt Dixon dixon@crd.ge.com

ralf@b.gp.cs.cmu.edu (Ralf Brown) (06/30/89)

In article <749@mitisft.Convergent.COM> dold@mitisft.Convergent.COM (Clarence Dold) writes:
}in article <2385@ur-cc.UUCP>, chu2_ltd@uhura.cc.rochester.edu (Jim Huang) says:
}> 	I would like to know how to open a large number of files at
}> 	once under MS-DOS 3.30.  For instance, if I want to open
}
}You might be encountering a compiler limitation.
}Microsoft QuickC won't open() files beyond the limit declared in stdio.h,
}even though that should have no effect unless you are trying to fopen().

Actually, open() has to keep info about the file handle, too.  After all,
you can open a file with either O_TEXT or O_BINARY, and the runtime library
has to know whether or not to perform newline conversion.  Also, (at least
in TurboC) specifying O_APPEND for open() tells write() to seek to the end of
the file before writing.
-- 
{harvard,uunet,ucbvax}!b.gp.cs.cmu.edu!ralf -=-=- AT&T: (412)268-3053 (school)
ARPA: RALF@CS.CMU.EDU     |"The optimist is the kind of person who believes a
FIDO: Ralf Brown 1:129/46 | housefly is looking for a way out."--Geo.J.Nathan
BITnet: RALF%CS.CMU.EDU@CMUCCVMA -=-=-=-=-=- DISCLAIMER? I claimed something?

kji@vpnet.UUCP (Ken Isacson) (06/30/89)

Jim,
   What version of MS-DOS are you using?  

   Also, bump you FILES= up a bit, like FILES=70 and possibly your
   BUFFERS= up to 70 also.  I am not sure if it will work or not,
   but is worth a try.  Also consult your OS manuals for those
   limits, it may give you a clue to the answer.

   For what application would you want to open so many files?
 
Ken Isacson

jim@ic2020.UUCP (Jim Carter) (06/30/89)

in article <2385@ur-cc.UUCP>, chu2_ltd@uhura.cc.rochester.edu (Jim Huang) says:
> 
> 
> 	I would like to know how to open a large number of files at
> 	once under MS-DOS 3.30.  ...
> 
> 	Jim Huang
> 	chu2_ltd@uhura.cc.rochester.edu  (128.151.224.17)
> 	University of Rochester
On simtel20, there is a file that might be of interest. Hope this helps.

disk+directory+file/description                    date/size

PD1:<MSDOS.DSKUTL>256FILES.ARC                     880829  
Hold open up to 256 files in DOS 3.xx              40815

-- 
Jim Carter (Sequoia Contact Lens,1355 11th Street,Reedley,CA,93654)
{...!csufres!csuf3b!ic2020!jim} 209/638-3939, Fax 209/638-5433