> Thanks for sharing Andrei. let me ask you a bit, this means you have
> to save first before accessing your own stack and restore it  after
> you leave it, right? Or is it unnecessary?
>
>

If you want to reuse the stack you were using before switching to the new
one, then yes, you have to save the stack pointer are restore it later.
There are portable ways of doing these; look at getcontext/setcontext.
People that would be interested in this sort of tricks are probably
implementing a threads library of sorts, so, for example, for forking, you'd
want to save the current context (savecontext), make a new one for the
second thread with a new stack (makecontext), use that context for a while
(setcontext) then revert to the original one (setcontext again).

Cheers,

- a_m



> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>

Reply via email to