Can't open more than 15 files simultaneously with MS-DOS

Discussions about using non Windows and Linux guests such as FreeBSD, DOS, OS/2, OpenBSD, etc.
Post Reply
gonza_ccba
Posts: 3
Joined: 26. Mar 2014, 19:50

Can't open more than 15 files simultaneously with MS-DOS

Post by gonza_ccba »

I'm currently trying to run a dos console application which has to open a certain number of files simultaneously ( more than 15 :roll: ). So i cofigured a ms-dos 6.22 vbox machine, with "files=100" in config.sys file, running over Ubuntu 12.04LTS 32-bit and vbox 4.3.8.
To try this i did a little C program that opens files:

Code: Select all

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<errno.h>


int main (void) {


 FILE *archivos[300];
 char numstr[15];
 int i=0,nmax=0;
 
 printf("\nHow many files do you want to open: ");


 scanf("%d",&nmax);
 for( i=0; i<nmax ; i++) {
   sprintf( numstr, "test%d.dat", i);


   if(!(archivos[i]=fopen( numstr ,"w")))
   {
     printf("\nCouldn't open file %s", numstr);
     printf("\nDescription: %s\r %d", strerror(errno), errno);
     printf("\nThe max open files was: %d", i);
     exit(1);
   }
 }
 
 printf("\nNo errors. The open files number is : %d\n", i);


 for( i=0; i<nmax; i++)
   fclose( archivos[i] ); 
 return( 0 );
}


And i got this results:
C:\>test
How many files do you want to open: 20
Couldn't open file test15.dat
Description: No such file or directory 2
The max open files was: 15
I don't have any idea what's happening, but i do know it's not only vbox guilt because i tried this program with dosemu and dosbox and got the same result, 15 files :x. So in this case it must be something between vbox and ubuntu.
Thanks for your help.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can't open more than 15 files simultaneously with MS-DOS

Post by Perryg »

Moving to other guests since.
michaln
Oracle Corporation
Posts: 2973
Joined: 19. Dec 2007, 15:45
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Any and all
Contact:

Re: Can't open more than 15 files simultaneously with MS-DOS

Post by michaln »

Why are you posting this here? It has nothingto do with virtualization. You'll get exactly the same result on a physical system running DOS. You're not doing yourselves any favors by blaming VirtualBox, it just hinders you in finding the actual solution.

Check your C compiler's documentation on how to increase the number of available stdio handles. Hint: the default limit is usually 20 handles and you've already used 5 for stdin, stdout, stderr, stdaux and stdprn.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Can't open more than 15 files simultaneously with MS-DOS

Post by mpack »

gonza_ccba wrote:i do know it's not only vbox guilt because i tried this program with dosemu and dosbox and got the same result, 15 files :x. So in this case it must be something between vbox and ubuntu.
Well there's a peculiar logical inference... Or perhaps a language problem?
gonza_ccba
Posts: 3
Joined: 26. Mar 2014, 19:50

Re: Can't open more than 15 files simultaneously with MS-DOS

Post by gonza_ccba »

michaln wrote: You'll get exactly the same result on a physical system running DOS
Well michaln, the thing is that if I'll get exactly the same result on a physical system then i would be able to open more than 15 files :shock:. This is done by setting the envirorment variable "files=nnn" (where nnn is the number of files you want to open) in config.sys configuration file of ms-dos. So i think this problem has something to do with virtualization. As this same C program running in pure linux can open as many files as i want.
Now what you are saying about buffers is that virtualbox ignores this "files" setting and only allow me to open 20 files.
mpack wrote: Or perhaps a language problem?
mpack, thanks for your answer. I don't think it's a language problem, as i tried the same C program in linux and opens more than 15 files. But I'll do some research about that.
My main issue is a console application that i need to run under dos, i know it opens many files, more than 15, or 20. And this console application keeps complaining about it's inability to open the files. So this is also evidence that my virtual ms-dos is not working as a physical system (mean not responding to the "files" setting in config.sys).
Last edited by gonza_ccba on 27. Mar 2014, 15:19, edited 1 time in total.
Martin
Volunteer
Posts: 2561
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Can't open more than 15 files simultaneously with MS-DOS

Post by Martin »

Are you really sure it has to do with the file setting?
Did you try with a MS-DOS system without Virtualbox?
Are you sure that your compiler uses the same (default?) values for the different target environments (DOS, Linux, ...)?
gonza_ccba
Posts: 3
Joined: 26. Mar 2014, 19:50

Re: Can't open more than 15 files simultaneously with MS-DOS

Post by gonza_ccba »

michaln wrote:Why are you posting this here? It has nothingto do with virtualization. You'll get exactly the same result on a physical system running DOS. You're not doing yourselves any favors by blaming VirtualBox, it just hinders you in finding the actual solution.

Check your C compiler's documentation on how to increase the number of available stdio handles. Hint: the default limit is usually 20 handles and you've already used 5 for stdin, stdout, stderr, stdaux and stdprn.
Michaln is right, I have to increase the number of handles. Thanks. Sorry for misunderstanding my issue.
Post Reply