JXS118@psuvm.psu.edu (Jeff Siegel, Op from Atherton Hall) (06/10/90)
Even though I have the statement FILES = 40 in my config.sys, DOS refuses to open more than 20 files at once and returns error code 4 (no handles available) if I try to open more. I've tested this on 3 different version of DOS (all of which allegedly support the FILES statement) Any clues why this is? A while back I remember seeing a question on how to get more than 20 open files in TurboC. I've come up with a solution to the limitation TurboC places on the number of open streams, but when I went to test it I ran into this DOS problem. I will post the code if I manage to get it working. Has a 'cure' for this problem already been posted on the net? (I don't want to repeat a lot of work someone else has already done) Jeff
silver@xrtll.uucp (Hi Ho Silver) (06/10/90)
In article <90160.191651JXS118@psuvm.psu.edu> JXS118@psuvm.psu.edu (Jeff Siegel, Op from Atherton Hall) writes:
$Even though I have the statement FILES = 40 in my config.sys, DOS refuses
$to open more than 20 files at once and returns error code 4 (no handles
$available) if I try to open more. I've tested this on 3 different version
$of DOS (all of which allegedly support the FILES statement) Any clues why this
$is?
Yup. Unless you fiddle DOS otherwise (and I forget how to), each process
is only allowed 20 file handles, irrespective of your FILES= statement. The
FILES= statement controls how many files can be open at once, not how many
one process can have open.
Keep in mind, also, that each process is provided with 5 file handles
already used (stdin, stdout, stderr, stdprn, and stdaux) so you really only
have 15 to work with.
The workaround involves using some DOS call that expands the table of
file handles for your process, but I've never done it and I can't recall
how to do it. I'm sure someone else will post it.
--
/Nikebo \ Nikebo says "Nikebo knows how to post. Just do it."\silver@xrtll/
/---------\_____________________________________________________\----------/
/yunexus!xrtll!silver (L, not 1)\ Hi Ho Silver \ just silver for short /
/Silver: Ever Searching for SNTF \ Life sucks. \ someone buy me a BEER! /
frisk@rhi.hi.is (Fridrik Skulason) (06/11/90)
In article <1990Jun10.151538.25462@xrtll.uucp> silver@.UUCP (PUT YOUR NAME HERE) writes: > The workaround involves using some DOS call that expands the table of >file handles for your process, but I've never done it and I can't recall >how to do it. I'm sure someone else will post it. Warning - this only works in DOS 3.3+ mov AH,67H mov BX,number_of_handles ; max 255 INT 21H -frisk -- Fridrik Skulason University of Iceland | Technical Editor of the Virus Bulletin (UK) | Reserved for future expansion E-Mail: frisk@rhi.hi.is Fax: 354-1-28801 |
toma@tekgvs.LABS.TEK.COM (Tom Almy) (06/11/90)
In article <1990Jun10.151538.25462@xrtll.uucp> silver@.UUCP (PUT YOUR NAME HERE) writes: >In article <90160.191651JXS118@psuvm.psu.edu> JXS118@psuvm.psu.edu (Jeff Siegel, Op from Atherton Hall) writes: >$Even though I have the statement FILES = 40 in my config.sys, DOS refuses >$to open more than 20 files at once and returns error code 4 (no handles >$available) if I try to open more. > Yup. Unless you fiddle DOS otherwise (and I forget how to), each process >is only allowed 20 file handles, irrespective of your FILES= statement. The >FILES= statement controls how many files can be open at once, not how many >one process can have open. > The workaround involves using some DOS call that expands the table of >file handles for your process, but I've never done it and I can't recall >how to do it. I'm sure someone else will post it. Well, the INT 21H call is: AH =67H BX = # desired handles It returns carry flag clear if successful. The function is only available in DOS versions >=3.3. *BUT* if you are using a C compiler, and the stdio package, then you have an additional hurdle. Every C compiler library I have seen maintains a static table for FILE, which has 20 entries. The only way I know to expand these tables is to have access to the library source, make the change, and recompile the library. If you use open(), read(), etc. (not stdio), or many other languages, then you are home free. Tom Almy toma@tekgvs.labs.tek.com Standard Disclaimers Apply
david@csource.OZ.AU (david nugent) (06/12/90)
>Even though I have the statement FILES = 40 in my config.sys, DOS refuses >to open more than 20 files at once and returns error code 4 (no handles >available) if I try to open more. I've tested this on 3 different version >of DOS (all of which allegedly support the FILES statement) Any clues why >this is? 20 files (including the standard 4 handles: stdin, stdout, stderr & stdin) is the _process_ limit for MS-DOS. The FILES= statement sets the global number of files available to all processes. DOS 3.10 above includes an undocumented way of increasing the number of handles available to a particular process. DOS 3.30 above has a documented way of achieving this. Rather than explain the fairly complex undocumented method, it's easier and cheaper to just make sure your program runs on DOS 3.30 or later (this is a reasonable requirement, IMO). The call you need is DOS Fn 67H. The specs for it are: AH = 67H BX = the desired number of handles (up to 0FFFFh) Returns: AX = error code if carry is set If BX is 20, then 20 is used. If BX is less than the current max and more than that many are currently open, then the change will take place when there are no more than the number of requested handles open. If BX is greater than the current max, then there must be enough memory available for the new file handle table. Once this takes effect, it remains in effect for ALL processes in the system. The number of files request can exceed the FILES= statement in CONFIG.SYS - which makes it sort of redundant. :-) Hope this helps, david -- Unique Computing Pty Ltd, Melbourne, Aust. david@csource.oz.au 3:632/348@fidonet 28:4100/1@signet
mat@zelator.UUCP (Matthias Barmeier) (06/13/90)
In article <90160.191651JXS118@psuvm.psu.edu> JXS118@psuvm.psu.edu (Jeff Siegel, Op from Atherton Hall) writes:
]Even though I have the statement FILES = 40 in my config.sys, DOS refuses
]to open more than 20 files at once and returns error code 4 (no handles
]available) if I try to open more. I've tested this on 3 different version
]of DOS (all of which allegedly support the FILES statement) Any clues why this
]is?
Try this :
MSDOS INT 21 with AX=6700h and BX=Number of handles to open.
This Msdos function returns in AX the error code if carry flag is set.
This call allows programs to control number of file handles available fo use.
Memory is allocated from memory freed by int 21 AX=4A00h. If number of handles
is less than current number of open files, change becomes effective when currentnumber of files drops below new limit.
INT 21 with AX=4A00h and BX=New requested block size in paragraphs (16 Byte).
and ES=Segment of Block to be modified.
I hope this will help you !
Ciao
mat@zelator.UUCP
shap@bunker.UUCP (Joseph D. Shapiro) (06/13/90)
In article <17@csource.OZ.AU> david@csource.OZ.AU (david nugent) writes:
] >Even though I have the statement FILES = 40 in my config.sys, DOS refuses
] >to open more than 20 files at once and returns error code 4 (no handles
]
] The call you need is DOS Fn 67H. The specs for it are:
] AH = 67H
] BX = the desired number of handles (up to 0FFFFh)
]
] Once this takes effect, it remains in effect for ALL processes in
] the system. The number of files request can exceed the FILES=
] statement in CONFIG.SYS - which makes it sort of redundant. :-)
]
] Hope this helps,
] david
1) this has effect only for the process which calls it.
2) the FILES= limit still applies.
3) i know both from personal experience.
--
__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__
Joe Shapiro "My other car is a turbo...
ISC-Bunker Ramo ...too."
{decvax,yale,philabs,oliveb}!bunker!shap
russ@m-net.ann-arbor.mi.us (Russ Cage) (06/16/90)
In article <90160.191651JXS118@psuvm.psu.edu> JXS118@psuvm.psu.edu (Jeff Siegel, Op from Atherton Hall) writes: >Even though I have the statement FILES = 40 in my config.sys, DOS refuses >to open more than 20 files at once and returns error code 4 (no handles >available) if I try to open more. I've tested this on 3 different version >of DOS (all of which allegedly support the FILES statement) Any clues why this >is? Down in the PSP of your process, there is a table which maps handle numbers for your process to DOS internal file reference numbers. (Examine the table and you will see entries of 01 for stdin, stdout, and stderr on an interactive process. I think 02 is stdprn unless redirected, dunno what 0 is. The unused entries are marked with 0xff.) This table is only 20 bytes long; it goes from PSP:0018 to PSP:002b. However, this table can be re-located. In DOS 3.x, there is a FAR pointer to the handle table at PSP:0034, and the length is at PSP:0032. So, by moving the table to an area of memory with more space, filling the remainder with 0xff, and changing the pointer to (and length of) the table in your PSP, your process can have more than 20 files open at once. I have done this, it works quite well. Condor 3 v. 2.20 uses it to good effect. My knowledge of this ends with DOS 3.x, there may be cleaner methods of doing this with more recent versions of DOS. -- I am paid to write all of RSI's opinions. Want me to write some for you? (313) 662-4147 Forewarned is half an octopus. Russ Cage, Robust Software Inc. russ@m-net.ann-arbor.mi.us