INF: Increasing the File Handle Limit in a Multithreaded App

ID Number: Q34386

5.10 6.00 6.00a

OS/2

Summary:

The maximum number of file handles available for a multithreaded

application in C 5.1, 6.0, and 6.0a is 40 by default. This limit

cannot be increased using the method described in the README.DOC

because the multithreaded startup code was not provided, only the

single-threaded.

In C 5.1, the number of available file handles cannot be changed from

its default of 40, even though the default number of file handles in

OS/2 is 255.

In C 6.0, a workaround is described in the README.DOC:

Multithread (MT) and Dynamic-Link Library (DLL) Libraries

By default, the C 6.0 MT and DLL libraries support 40 file handles

and streams instead of 20, which is the single thread library

default.

To increase the number of file handles (low-level I/O), simply

issue a DOSSETMAXFH call from within your program. This increases

the open file limit for the calling process.

To increase the allowable number of open streams, first make sure

that the number of file handles is greater than or equal to the

number of streams you want. Then rebuild module _FILE.C with the

desired _NFILE setting (as described under the single thread

description). Since the MT and DLL libraries are large model, be

sure to compile _FILE.C with the /AL switch.

Additional reference words: 5.10 6.00 6.00a