FOPEN_MAX , SYS_OPEN

R

ravi

Hello friends

I am currently porting an administration software package from UNIX to
DOS.

The package is written in C and uses C-ISAM. I am using the Microsoft
C/C++ compiler for DOS. I do not use C++, just straight vanilla C. The
software uses a lot of simultaneously open files. I now have a problem
which may be related to a limitation in the maximum number of open files
simultaneously.

I have found two definitions in stdio.h that do not make me too happy.
FOPEN_MAX is set to 18 and SYS_OPEN to 20 ( or maybe the other way
around ). When consulting the Help it tells me that this determines the
maximum of simultaneously open files. I would very much appreciate if
someone who knows about this can point me in the right direction.

Is it possible to change these constants ? Does the FILES= parameter in
config.sys not count at all ? Am I completely on the wrong track ? How is
the weather where you live ?

Thank you in advance.
 
S

Sjouke Burry

ravi said:
Hello friends

I am currently porting an administration software package from UNIX to
DOS.

The package is written in C and uses C-ISAM. I am using the Microsoft
C/C++ compiler for DOS. I do not use C++, just straight vanilla C. The
software uses a lot of simultaneously open files. I now have a problem
which may be related to a limitation in the maximum number of open files
simultaneously.

I have found two definitions in stdio.h that do not make me too happy.
FOPEN_MAX is set to 18 and SYS_OPEN to 20 ( or maybe the other way
around ). When consulting the Help it tells me that this determines the
maximum of simultaneously open files. I would very much appreciate if
someone who knows about this can point me in the right direction.

Is it possible to change these constants ? Does the FILES= parameter in
config.sys not count at all ? Am I completely on the wrong track ? How is
the weather where you live ?

Thank you in advance.
Dos is a hurdle as you found out, but also dos compilers,
or maybe both.
The solution for me was, DONT OPEN TO MANY FILES!!!
15 or 16 was the limit , and fiddeling with config.sys
did not help much.
In some cases I just ran the software twice, with a command line
parameter telling wich batch of outputfiles to open.
That worked (sort of).
Silly example: (batch variable as control)
if(batch==1)f_speed=fopen("results\\speed.dat","w");
if(batch==1)f_speed_sd=fopen("results\\speedsd.dat","w");
if(batch==1)f_stuur_sd=fopen("results\\stuursd.dat","w");
if(batch==1)f_hfa =fopen("results\\hfa.dat","w");
if(batch==1)f_war_min=fopen("results\\warmin.dat","w");
if(batch==1)f_war_prc=fopen("results\\warprc.dat","w");
if(batch==1)f_war_min_l=fopen("results\\warmin_l.dat","w");
if(batch==1)f_war_prc_l=fopen("results\\warprc_l.dat","w");
if(batch==1)f_war_min_r=fopen("results\\warmin_r.dat","w");
if(batch==1)f_war_prc_r=fopen("results\\warprc_r.dat","w");
if(batch==2)f_tlc_1_l =fopen("results\\tlc_1_l.dat","w");
if(batch==2)f_tlc_m_l =fopen("results\\tlc_m_l.dat","w");
if(batch==2)f_tlc_1_r =fopen("results\\tlc_1_r.dat","w");
if(batch==2)f_tlc_m_r =fopen("results\\tlc_m_r.dat","w");
if(batch==2)f_baan =fopen("results\\baan.dat","w");
if(batch==2)f_baan_l =fopen("results\\baan_l.dat","w");
if(batch==2)f_baan_r =fopen("results\\baan_r.dat","w");
if(batch==2)f_baan_sd =fopen("results\\baan_sd.dat","w");

repeating that at the write result locations,
and again at the file closing stage.......
Well, it works.
This was with the 32 bit WATCOM C/C++ compiler for DOS.
 
J

jacob navia

ravi a écrit :
Hello friends

I am currently porting an administration software package from UNIX to
DOS.

Dos is obsolete since at least 15 years

Why are you doing this?
 
S

Sjouke Burry

ravi said:
Hello friends

I am currently porting an administration software package from UNIX to
DOS.

The package is written in C and uses C-ISAM. I am using the Microsoft
C/C++ compiler for DOS. I do not use C++, just straight vanilla C. The
software uses a lot of simultaneously open files. I now have a problem
which may be related to a limitation in the maximum number of open files
simultaneously.

I have found two definitions in stdio.h that do not make me too happy.
FOPEN_MAX is set to 18 and SYS_OPEN to 20 ( or maybe the other way
around ). When consulting the Help it tells me that this determines the
maximum of simultaneously open files. I would very much appreciate if
someone who knows about this can point me in the right direction.

Is it possible to change these constants ? Does the FILES= parameter in
config.sys not count at all ? Am I completely on the wrong track ? How is
the weather where you live ?

Thank you in advance.

Oh and the weather is fine, hot summer turned into balmy spring weather.
(Netherlands).
 
J

jacob navia

John Kelly a écrit :
Not every application calls for Windows bloatware.

Please do not start complainig about FOPEN_MAX then.

You have 640K and 15 files open. PERIOD.
 
J

John Kelly

John Kelly a écrit :
Please do not start complainig about FOPEN_MAX then.
You have 640K and 15 files open. PERIOD.

http://www.delorie.com/gnu/docs/glibc/libc_179.html

Macro: int FOPEN_MAX
The value of this macro is an integer constant expression that
represents the minimum number of streams that the implementation
guarantees can be open simultaneously. You might be able to open
more than this many streams, but that is not guaranteed
In POSIX.1 systems this value is determined by the OPEN_MAX parameter

http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html

The minimum value for {OPEN_MAX} is 20. This is a FIPS requirement.
{OPEN_MAX}
Maximum number of files that one process can have open at any one time.
Minimum Acceptable Value: {_POSIX_OPEN_MAX}
{_POSIX_OPEN_MAX}
Maximum number of files that one process can have open at any one time.
Value: 20


Twenty is a lot. If you need more, maybe you're doing too much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top