C (72/254)

From:Gregory Roberts II
Date:20 Apr 00 at 10:05:43
Subject:Re: How to change stack

Hi Andrzej,

On Thu, 20 Apr 2000, Andrzej J. Debicki wrote:

> Thanks. I wrote some test proggy. But something id wrong. It hangs on
> first StackSwap func. Can someone help me to solve that?
>
> #include <exec/memory.h>
> #include <exec/types.h>
> #include <clib/alib_protos.h>
>
> int main(void)
> {
> struct StackSwapStruct *pNewStack;
> struct Task *pTask;
> APTR pStackMem;
> ULONG lStackSize;
>
>[rest of code snipped]
>

Well, you probably don't want some of these living on the stack, since
you're swapping it out. :-) From a quick glance, I'd say at least
pNewStack and pStackMem should be declared outside of main().

You can probably get away without copying the contents as long as you swap
the stack back within the same function and don't use any variables
declared on the stack or passed in as parameters. (some of the parameters
might be in registers instead of on the stack, but why take chances? )
Of course, once you swap the stack back (within the same function) you're
free to use all those things again.

Hope this helps,
Greg



gregr@en.com
KC8BGC
Amiga Enthusiast :)
IBM programmer :(

------------------------------------------------------------------------
Enjoy the award-winning journalism of The New York Times with
convenient home delivery. And for a limited time, get 50% off for the
first 8 weeks by subscribing. Pay by credit card and receive an
additional 4 weeks at this low introductory rate.
http://click.egroups.com/1/3102/1/_/451227/_/956221702/
------------------------------------------------------------------------