🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #3137

Re: Recovering a Dead Thread's Stack, etc.

#3137
From: Oleg Vishnepolsky
Date: Tue, 21 May 1991 19:33
30 lines
1942 bytes
In  <24884@well.sf.ca.us>  shiva@well.sf.ca.us (Kenneth Porter) writes:
>
> How can I tell when a thread is dead and its resources
> (especially its stack) can be reclaimed?  Presumably the thread
> can't free its own stack since it needs it to call DosExit().
> One can't tell that a thread is dead by testing for its ID
> with, say, DosSuspendThread() (looking for the
> ERROR_INVALID_THREADID) since another thread might be created
> that would pick up a dying thread's ID.  Presumably
> _beginthread() accomplishes the stack reclamation, since my
> company has an application that spawns short-run threads left
> and right with it and it doesn't lose memory over time.
>
> Ken (shiva@well.sf.ca.us)

Microsoft C compiler 6.0 frees application developers of necessity
to allocate their own stack. If you specify stack pointer as NULL,
then run-time library takes care of allocating the stack for you.
Then when the thread dies, the run-time deallocates the stack
for you. This way you bypass the whole problem of recovering the stack.

I am quoting from Microsoft C Advanced Programming Techniques:

"If you specify NULL for the stack address, _beginthread manages
allocation and deallocation of the thread stack for you. This
option is advantageous because it is difficult for your program
to determine when  a thread has terminated, so you cannot know
when to deallocate the thread stack".

Oleg Vishnepolsky
Technical Details
Message-ID: <1991May21.193358.16651@watson.ibm.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!crdgw1!uunet!bywater!arnor!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!crdgw1!uunet!bywater!arnor!news
From: oleg@watson.ibm.com (Oleg Vishnepolsky)
Newsgroups: comp.os.os2.programmer
Subject: Re: Recovering a Dead Thread's Stack, etc.
Message-ID: <1991May21.193358.16651@watson.ibm.com>
Date: 21 May 91 19:33:58 GMT
Sender: news@watson.ibm.com (NNTP News Poster)
Organization: IBM T.J. Watson Research Center
Lines: 30
Nntp-Posting-Host: rachel