TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Henk den Adel
from: Murray Lesser
date: 1997-03-19 21:50:04
subject: trap 0005

Excerpted from message dated 03-18-97, Paul Edwards to Henk den Adel:

HdA> I would appreciate if anyone could explain me why the stack is not 
HdA> automatically chosen to be sufficiently large, or better how to

PE>Much easier to allow the user to specify the stack size!

HdA> order the compiler to choose the right stack size. I'm using ibm's C 
HdA> compiler, version 2.01.

Hi Henk--

    PMFJI at this late date, but I apparently missed the beginning of
this thread.  If you are using a good compiler designed for OS/2 2.x (or
later), it doesn't cost anything to over-specify stack size.  Stack will
be loaded into "real" memory only as needed, one 4K page at a time, as
long as there is still any committed stack address space.  So it is a
false economy (under OS/2) to try to save memory by minimizing committed
(specified) stack space.

    I don't program in C any more, but I have ILINK (the new IBM 32-bit
linker) set up for 2MB stack size for any PL/I program I write.  (I
suppose I could run out of memory-address space for that process, but
I've never gotten anywhere near it!)  An example: one of my little PL/I
multitasking utilities has a 2 MB stack specified (committed address
space) for the main thread, and a 1 MB stack for the secondary.
According to OS20MEMU, the program only occupies 216 KB of real memory
after the secondary thread kicks in.  The rest of the committed stack
space is just sitting around in address space, just in case.

    However, you have to be sure your compiler takes advantage of the
OS/2 memory-management system this way.  You can test your compiler:
Check out what happens to "in-memory" usage as you increase the
committed stack address space on a working program.  My PL/I for OS/2
compiler does so, and I am fairly certain the IBM C/C++ does, too (they
have the same back end).  I know that Borland's OS/2 compilers don't.  I
can't speak for any of the others.

    Regards,

          --Murray

___
 * MR/2 2.25 #120 * Watching for speed bumps on the Information Highwy

--- Maximus/2 2.02
* Origin: OS/2 Shareware BBS, telnet://bbs.os2bbs.com (1:109/347)
SEEN-BY: 50/99 54/99 270/101 620/243 625/155 711/401 413 430 934 712/311 407
SEEN-BY: 712/505 506 517 623 624 704 713/317 800/1
@PATH: 109/347 632 7 396/1 270/101 712/624 711/934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.