makecontext , swapcontext
- modify and exchange user thread contexts
#include <ucontext.h> void
Fa ucontext_t *ucp
Fa void lp]*funcrp]lp]voidrp]
Fa int argc ...
Fc Ft int
swapcontext (ucontext_t *oucp const ucontext_t *ucp);
modifies the user thread context pointed to by
Fa ucp ,
which must have previously been initialized by a call to
and had a stack allocated for it.
The context is modified so that it will continue execution by invoking
with the arguments provided.
must be equal to the number of additional arguments provided to
and also equal to the number of arguments to
or else the behavior is undefined.
must be initialized before calling
and determines the action to take when
if equal to
the process exits;
is implicitly invoked.
saves the current thread context in
the currently active context.
otherwise -1 is returned and the global variable
is set appropriately.
will fail if:
Bq Er ENOMEM
There is not enough stack space in
to complete the operation.