limburg@batcomputer.tn.cornell.edu (Karin Limburg) (08/02/87)
A friend of mine (seriously!) has a programming problem with Turbo-Pascal. Can somebody post an e-mail response to this query? The question concerns the number of files that can be opened simultaneously under DOS 3.0 using Turbo Version 3. He has used the {$F} compiler directive in his code to set the number of open files to 25 (i.e. {$F25} ). In the CONFIG.SYS file he set files=35 and buffers=40. The Turbo compiler gives no error messages, but the program crashes after 15 files have been opened, (not 16 as default is specified in the manual). What gives? Any help much appreciated. Also, DOS apparently doesn't complain about the number of files open until you exceed 255. Karin Limburg limburg@tcgould.tn.cornell.edu or apij@cornella.bitnet
darrylo@hpsrlc.UUCP (08/03/87)
In comp.sys.ibm.pc, limburg@batcomputer.tn.cornell.edu (Karin Limburg) writes: > A friend of mine (seriously!) has a programming problem with Turbo-Pascal. Can somebody post an e-mail response to this query? The question concerns the number of files that can be opened simultaneously under DOS 3.0 using Turbo Version 3. He has used the {$F} compiler directive in his code to set the number of open files to 25 (i.e. {$F25} ). In the CONFIG.SYS file he set files=35 and buffers=40. The Turbo compiler gives no error messages, but the program crashes after 15 files have been opened, (no t 16 as default is specified in the manual). What gives? Any help much appreciated. > > Also, DOS apparently doesn't complain about the number of files open until you exceed 255. > > Karin Limburg > limburg@tcgould.tn.cornell.edu or > apij@cornella.bitnet > ---------- [ Uhh -- Could you please break your message into 80-character (or less) lines? It's a bit difficult reading a paragraph as one long line. ] The problem here is that, while DOS allows up to 255 processes (in the more recent versions), EACH PROCESS is limited to 20 (twenty) SIMULTANEOUSLY open files. There are ways around this (more on this later). When a program is run four (more? -- I can't remember) handles are taken up by stdin, stdout, stderr, and stdaux, hence the magic number 16. Hmmm. I seem to recall that there is also a stdprn, which would account for the number 15, but I'm not sure. If you're not going to use some of these automatically opened handles, you can simply close them. However, even if you close all of these handles, you're still not going to get more than 20 handles per process (program). As your friend (really? ;-) is programming in Turbo Pascal, he (she?) is in luck. Someone (Neil Rubenking?) has written a few routines that allows a Turbo Pascal program to have up to 255 (I think) simultaneously open files. It can be found in the Borland Languages SIG on CompuServe and on some BBSes. If you want it and have trouble finding it, send me Email and I'll see what I can do. If you want a more detailed explanation of what's going on, send me a mailing address and I'll send you a copy of a column from a magazine (if I can find it); several months back, Ray Duncan's "16-Bit Toolbox" column in Dr. Dobb's Journal had an excellent discussion on the problem, as well as two ways around it. -- Darryl Okahata {hplabs!hpcea!, hpfcla!} hpsrla!darrylo CompuServe: 75206,3074 Disclaimer I: the above is the author's personal opinion and is not the opinion or policy of his employer or of the little green men that have been following him all day. Disclaimer II: I have no connections with Borland or CompuServe, other than as a customer.