home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / msdos / misc / 4479 < prev    next >
Encoding:
Text File  |  1992-07-21  |  3.9 KB  |  132 lines

  1. Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!sun-barr!ames!pacbell.com!att!ucbvax!bloom-beacon!bloom-picayune.mit.edu!ankleand
  2. From: ankleand@mtl.mit.edu (Andrew Karanicolas)
  3. Newsgroups: comp.os.msdos.misc
  4. Subject: Help with Segmented Memory Architecture and Borland C++ (long)
  5. Message-ID: <1992Jul21.201248.17228@athena.mit.edu>
  6. Date: 21 Jul 92 20:12:48 GMT
  7. Sender: news@athena.mit.edu (News system)
  8. Organization: MIT Microsystems Technology Laboratories
  9. Lines: 120
  10. Nntp-Posting-Host: mtl.mit.edu
  11.  
  12.  
  13. Hello,
  14.  
  15. I've got some questions about memory on a Dell 316SX machine with 8M of
  16. total memory and DOS v5.0.  This question relates to a C program
  17. compiled with the Borland C++ compiler v3.0.
  18.  
  19. In essence, I want things like 2M arrays; 512K points of long int
  20. data.  Since a long int is 4 bytes on the 386, the total array amounts
  21. to 2M I believe.
  22.  
  23. Here is the C program:
  24.  
  25.     #include <stdio.h>
  26.     #include <conio.h>
  27.     #include <dos.h>
  28.     #include <alloc.h>
  29.  
  30.     main()
  31.     {
  32.     long j;
  33.     long *a;
  34.  
  35.     a = (long *) farcalloc(524288, sizeof(long));
  36.  
  37.     printf("hello world\n");
  38.  
  39.     for(j = 0; j <= 524287; j++)
  40.       {
  41.       a[j] = 0;
  42.       printf("j = %ld\n", j);
  43.       }
  44.  
  45.     farfree(a);
  46.  
  47.     printf("goodbye world\n");
  48.  
  49.     return 0;
  50.     }
  51.  
  52. Here is config.sys:
  53.  
  54.     DEVICE=C:\DOS\SETVER.EXE
  55.     FILES=30
  56.     BUFFERS=30
  57.     BREAK=ON
  58.     DEVICE=C:\DOS\HIMEM.SYS
  59.     DEVICE=C:\DOS\EMM386.EXE 4096
  60.     DEVICE=C:\DOS\ANSI.SYS
  61.     DEVICE=C:\DOS\SMARTDRV.SYS
  62.     SHELL=C:\DOS\COMMAND.COM C:\DOS\ /E:1024 /p
  63.     DOS=HIGH
  64.  
  65. Here is autoexec.bat:
  66.  
  67.     @ECHO OFF
  68.     REM SET COMSPEC=C:\DOS\COMMAND.COM
  69.     PATH C:\DOS;C:\WINDOWS;C:\PRINTGL;C:\BIN;C:\BORLANDC\BIN;C:\
  70.     PROMPT $P$G
  71.     SET TEMP=C:\WINDOWS\TEMP
  72.     MOUSE /Y >NUL
  73.     WIN
  74.  
  75. Here is what the machine reports when mem is issued in DOS:
  76.  
  77.         655360 bytes total conventional memory
  78.         655360 bytes available to MS-DOS
  79.         582240 largest executable program size
  80.  
  81.        4587520 bytes total EMS memory
  82.        4194304 bytes free EMS memory
  83.  
  84.        6553600 bytes total contiguous extended memory
  85.              0 bytes available contiguous extended memory
  86.        1929216 bytes available XMS memory
  87.                MS-DOS resident in High Memory Area
  88.  
  89. If it helps, I can supply the output of mem with /debug option.
  90.  
  91. When the C program is run, it gets up to about j = 12 and then just
  92. hangs :)  A full hardware reset is needed to get out (power cycle).
  93. The program was compiled using the 'large' memory model of Borland
  94. C++ v3.0:
  95.  
  96.     bcc -ml memtest1.c
  97.  
  98. I called Borland technical support to see what the deal was.  The
  99. interesting thing was that the person I spoke to said that v3.0 does
  100. not deal with more than 640K to 1M of memory.  To use more, a 
  101. "DOS Extender" is needed.  Apparently, several companies are in
  102. business of providing these things; Borland is not one of them.  I got
  103. a phone number for a company called Phar-Lap and I am waiting for a
  104. call back.  Another company called Toolmaker, another called Ergo
  105. but no phone number for Ergo.  
  106.  
  107. If you were to look in the v3.0 manual "Programmer's Guide" pp.
  108. 339-365, DOS memory management is dealt with.  The technical support
  109. guy said flat out that the table is wrong on p. 349 indicating code
  110. size vs. data size for the various memory models.  This table shows
  111. that the large memory model can handle up to 16M of data and 16M of
  112. program.  How could Borland print such an egregious error?  The
  113. technical support guy claims that 1M is basically the limit of Borland
  114. as it stands.
  115.  
  116. Still with me :)  Do I _need_ this DOS extender?  Can you recommend a
  117. company to get one from?  I'm surprised Borland does not presently
  118. have one though the technical support guy said one is in the works
  119. along with a toolset for OS/2.  I guess I should ask this: How does a C
  120. program that I write know whether to access extended or expanded memory?
  121.  
  122. I am really learning to dislike segmented memory on a PC but I am
  123. forced to use it.
  124.  
  125. Thanks for any help, especially if you have read this far.  Please
  126. send e-mail if you contribute.
  127.  
  128. -- 
  129. Andrew Karanicolas
  130. MIT Microsystems Technology Laboratory
  131. ankleand@mtl.mit.edu
  132.