TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Erik Huelsmann
from: Mike Bilow
date: 1996-02-06 00:46:04
subject: Secondary thread / Guard-page excep

Erik Huelsmann wrote in a message to all:

 EH> My problem is this: I start the thread with a stack of some
 EH> size (tried different sizes). 
 EH> Then the thread-function calls some routines local to the
 EH> application. Nothing wrong yet, but as soon as I want to
 EH> initialise the thread to open an Object window, using
 EH> WinInitialize, I get a Guardpage exception. (I tried sizes:
 EH> $4000,32768,81*1024*1024)

 EH> I did not install an exception handler for this secondary
 EH> thread, but the compiler's runtime-library does not seem to
 EH> install one for the main thread and does not seem to have
 EH> any problems in stack-expansion.... 

I don't know anything about your SpeedPascal/2 tools, but most C compilers
have run-time libraries which wrap the thread start call with some private
setup, usually named "__beginthread()."  Generally, most
libraries allow passing NULL stack, in which case one will be allocated by
the library.  As far as I know, they all supply their own guard page
exception handlers.

 EH> PS: I did try to run the thread using the Commit-stack
 EH> option. This does the trick, but I don't want to be placed
 EH> back into the 16-bit age where I need to try to determine
 EH> the max. size my stack will grow to.

It is not the job of the operating system to allocate your memory for you,
but only to gracefully notify you of the need to do so.  This is done for a
very good reason.  There are a number of algorithms used to try to minimize
thrashing of the stack allocator, the simplest and most common being to
double the stack size on each exception.  However, all such algorithms have
some cases in which they will enter pathological breakdown, and the choice
of the right algorithm is far from simple.
 
-- Mike


--- 
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 323/107 170/400 396/1 270/101 712/515 711/808 809 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™.