delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/02/11/02:31:18

Date: Tue, 11 Feb 92 18:07 +1100
From: Bill Metzenthen <APM233M AT vaxc DOT cc DOT monash DOT edu DOT au>
Subject: Re: Suggested change to go32
To: djgpp AT sun DOT soe DOT clarkson DOT edu, dj AT ctron DOT com
Status: O

> DJ Delorie's message of 11-FEB-1992 03:37:48.01 says:

>Everyone seems to think that calling DOS function 0x67 will increase
>the number of available files.  IT WON'T.  Why?  Because some versions
>of Turbo C have a fixed length array (20) of information about the
>files, and if you open too many, you crash.  Replacing this method is
>on my list of things to do, but it's a major rewrite to transfer the
>Turbo functionality into libc.a.

Whoops! I have Turbo C++ V1.0 and I tried my suggestions on a couple
of programs and experienced no problems. I was lucky. I have looked
further into the matter and it is clear that my suggested method of
increasing the number of handles should be discarded.

However, my "suggested modifications" contained two suggestions. It
would be a pity for the better suggestion to be overlooked because of
the problems with the flawed one.

Below is the essence of the better suggested modification to DJGPP:

MSDOS gives just 20 handles to a process (which may be subsequently
increased). Of these, five are already in use; being stdin, stdout,
stderr, stdaux, and stdprn. go32 (as of version 1.05) uses another
four handles, leaving just eleven spare handles for the program.

Three of the handles used by go32 are an inevitable consequence
of the way in which go32 works. However, the fourth one arises from
an apparent oversight! A file is opened, examined, and then the
handle is never used again. A simple change to control.c allows this
handle to be recovered for use by programs.

The following is a diff to add the close() function.

---------------------------- snip snip ---------------------------------
diff -c old/control.c ./control.c
*** old/control.c	Mon Aug 26 07:26:34 1991
--- ./control.c	Wed Feb 12 03:37:26 1992
***************
*** 13,18 ****
--- 13,19 ----
  */
  
  /* Modified for VCPI Implement by Y.Shibata Aug 5th 1991 */
+ /* Added file close(). W Metzenthen 9th Feb 1992 */
  /* History:87,1 */
  #include <dos.h>
  #include <stdlib.h>
***************
*** 350,355 ****
--- 351,357 ----
      if (header[0] == 0x010b)
        self_contained = 1;
    }
+   close(n);	/* Give the handle back to MS-DOS (precious resource). WM */
  
    if (self_contained)
    {
***************
*** 388,395 ****
      else /* found */
      {
        debug_mode = 0;
!       paging_set_file(argv0);
!       emu_installed = emu_install(emu_fn);
        set_command_line(argv, envp);
  #if DEBUGGER
        syms_init(argv0);
--- 390,400 ----
      else /* found */
      {
        debug_mode = 0;
! 
!       paging_set_file(argv0);	/* Open the file 'argv0' to be paged in/out. */
! 
!       emu_installed = emu_install(emu_fn);	/* Open the file 'emu_fn' to
! 						   be paged in/out. */
        set_command_line(argv, envp);
  #if DEBUGGER
        syms_init(argv0);
***************
*** 400,406 ****
    if (set_brk)
      paging_brk(0x8fffffffL);
  
!   dalloc_init();
    init_controllers();
    if (emu_installed)
    {
--- 405,411 ----
    if (set_brk)
      paging_brk(0x8fffffffL);
  
!   dalloc_init();	/* Opens the swap file. */
    init_controllers();
    if (emu_installed)
    {
---------------------------- snip snip ---------------------------------

Bill Metzenthen

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019