[Stackless] can it be done with setjmp/longjmp?
tismer at tismer.com
Wed Feb 27 12:44:52 CET 2002
Russ Cox wrote:
>>[proposal about using setjmp/longjmp and alloca as a
>>``portable'' fall back for switching stacks]
> This seems like a terrible idea. Using alloca to put an entire
> stack frame back doesn't even seem like it would work, and
> if it did would depend on the underlying compiler and
> machine architecture. At this point you might as well just
> write the ten lines of assembly to do the stack switching.
It does work, but it is in fact a hack.
My problem is that I want to grow and shrink the stack
inplace. Using setjmp/longjmp would force me to use
a second, temporary stack while I'm restoring the real
stack. Alloca can save this second stack.
> If you mean how portable is a setjmp/longjmp-based coroutines
> implementation (which seems like a more likely question), the answer
> is fairly portable. I've written and run coroutine packages based
> on setjmp and longjmp on a number of systems. As mentioned
> in the pth paper, sometimes setjmp and longjmp are buggered and
> don't allow use for coroutine-like applications, but writing your
> own isn't hard. It's between five and twenty lines of assembly
> depending on the number of registers that need saving; you
> write it once and don't worry about it after that.
Well, I will stick with the 9 lines of assembly for now :-)
ciao - chris
Christian Tismer :^) <mailto:tismer at tismer.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net/
14163 Berlin : PGP key -> http://wwwkeys.pgp.net/
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
where do you want to jump today? http://www.stackless.com/
Stackless mailing list
Stackless at www.tismer.com
More information about the Stackless