From: brian%jaguar.cs.utah.edu@cs.utah.edu (Brian Sturgill)
Subject: Re: OS/2 vs NT features list, Revision 1.2
Date: 1 Sep 92 00:02:13 MDT
Organization: University of Utah CS Dept

In article <a+jnr7.msmith@netcom.com> msmith@netcom.com (Martin P. Smith) writes:
>In article <1992Aug31.164630.13859@hellgate.utah.edu> brian%jaguar.cs.utah.edu@cs.utah.edu (Brian Sturgill) writes:
>>	
>>	Automatic stack expansion.
>>		I am certain that OS/2 does not do this.
>>		OS/2 has you specify a limit on the stack size, but allocates
>>		only one page of the stack at a time, using a guard page
>>		technique to expand the stack.  When you hit the
>>		stack size limit your process dies.  Why they went most
>>		of the way, instead of all the way, I really cannot say.
> 
>Sorry but you are WRONG.

No, I am NOT WRONG.  If you read your own quote below carefully, you'll
see that it doesn't contradict what I said above.
If you want to see for yourself that OS/2 does indeed set a stack limit
per process, use the following program:

		#include <stdio.h>

		void t(int);

		void main(void)
		{
		t(1);
		}

		void
		t(int n)
		{
		char buf[4096];
		if (n > 10)
			return;
		buf[0]='\0';
		printf("%d\n", n);
		t(n+1);
		}

If you compile this: icc t.c
It crashes after printing "1".

If you compile this: icc /b/stack:32768 t.c
It crashes after printing "8".

If you compile this on a Unix system which has dynamic stack expansion,
it runs just fine.


>
>Please check the OS/2 technical library Programming Guide volume 2 Page 6-7
>text below Table 6-1. ( The Programming guide volumes in the library 
>are worth buying in my opinion ) 
>
>
>"The guard page attribute is intended to provide automatic stack growth
>and stack limit checking. An application can also use it in other data
>structures such as arrays. For example if an application is using an 
>array of 4096 bytes (one page) the application can allocate and commit
>two pages, one with read and write access and one designated as a gaurd
>page. If the application tries to write past the end of the array a
>page guard exception will be generated.
>
>Any reference-read,write or execute- to a guard page causes an access violation
>page fault to be generated. This fault causes a Guard Page Entered exception  
>to occur for the thread that referred to the guard  page. The exception can 
>be handled by the exception handler for the process, if one is registered.
>If the process does not have an exception handler registered, the systems i
>default exception handler will handle the exception. The default action by 
>the system exception handler is to convert the gaurd page to a commited
>page, then try mark the next page in memory as a gaurd page. If the systemi
>is not successful in marking the next page as aguard page, an
>Unable-TO-Grow-Stack exception occurs. The thread is allowed to continue 
>execution, but must be aware that it has at most 4KB of stack remaining."
>
>
>The paragraphs above CLEARLY show that OS/2 CAN dynamically grow the stack.
>
>All typos in the above (and lack of punctuation) are my fault. The above is 
>reproduced without permission. I felt it was important that we show the truth.
>
>
>Martin P. Smith
>msmith@netcom.com

Brian
-- 
C. Brian Sturgill                       *** OS/2 2.0 is for YOU! ***
University of Utah                  Microsoft needs some competition, but
Center for Software Science        -I- want to be one of the many using NT.
brian@cs.utah.edu; CIS: 70363,1373           :-) :-) :-)
Newsgroups: comp.os.os2.advocacy