It’s a simple thing to allocate your own stack and switch to it, if stack
size is a problem. But why not have a shared “guardian” thread, put the
stuff you want to share in TLS, and pass the address to the other threads ?
Stacks weren’t meant to be shared by coroutines !
Alberto.
-----Original Message-----
From: Johnny [mailto:xxxxx@yahoo.de]
Sent: Thursday, May 02, 2002 3:57 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Sharing stack-allocated data between threads
Kernel stack is 8KB. not so big but as long as there are not so many nested
functions, it is pretty improbable that you run out of
stack…IRQL>APC_LEVEL and the fact that kernel stack can be swapped out are
more dangerous; you can lock the physical pages or make the thread to wait
on a dispatcher object and use KernelMode as WaitMode in
KeWaitForSingleObject, in this case the thread stack is not swapped
out…but lots of other problems… NPP is the right way.
Johnny
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Peter Wieland
Sent: Donnerstag, 2. Mai 2002 19:16
To: NT Developers Interest List
Subject: [ntdev] RE: Sharing stack-allocated data between threads
you also need to be careful about the amount of stack space you use
doing this. kernel stacks do not grow and aren’t very big … if you
run off the end of them the system will bugcheck. This may not seem
like a big deal if your driver is on the top of the stack, but for those
of us at the bottom it’s a real pain.
-p
-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Thursday, May 02, 2002 10:02 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Sharing stack-allocated data between threads
Actually it is done frequently. For example, a stack allocated event
object may be used as IO completion context. You do have to be very
careful that the owning thread’s stack is not paged out if the users can
be running at >= DISPATCH_LEVEL.
-----Original Message-----
From: int3 [mailto:xxxxx@aalayance.com]
Sent: Thursday, May 02, 2002 12:44 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Sharing stack-allocated data between threads
No, You cannot - I am sure, u will screw me, if u use my thread stack

----- Original Message -----
From: Chtchetkine, Vladimir
To: NT Developers Interest List
Sent: Thursday, May 02, 2002 9:46 PM
Subject: [ntdev] RE: Sharing stack-allocated data between threads
Nope! I’m refering to KM thread stack.
-----Original Message-----
From: Paul Bunn [mailto:xxxxx@UltraBac.com]
Sent: Thursday, May 02, 2002 8:54 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Sharing stack-allocated data between threads
I’m assuming you’re refering to user-mode.
Since all memory in a process is shared between all threads of that
process, the stacks all share the same process memory so you can “get
at” other threads’ memory. However, there is the obvious problem that
if a function returns all its stack data is invalidated and be
overwritten by the next stack usage. So, the answer is “yes, if you’re
very careful”. Regards
Paul Bunn, UltraBac Software, 425-644-6000
Microsoft MVP - NT/Windows 2000/XP
http://www.ultrabac.com
-----Original Message-----
From: Chtchetkine, Vladimir [mailto:xxxxx@starbase.com]
Sent: Thursday, May 02, 2002 7:23 AM
To: NT Developers Interest List
Subject: [ntdev] Sharing stack-allocated data between threads
Hi everyone!
It’s a kind of paranoid question, but can I share stack-allocated data
between different threads?
I mean can thread stack be viewed as “just another pool” of memory that
is available from all other
threads?
Sorry, I guess it’s been too much of work and beer yesterday 
You are currently subscribed to ntdev as:
xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@aalayance.com To
unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@yahoo.de
To unsubscribe send a blank email to %%email.unsub%%
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%
The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.