1 .TH MAKECONTEXT 3 "Mar 2, 2010"
3 makecontext, swapcontext \- manipulate user contexts
9 void makecontext(ucontext\_t *\fIucp\fP, void \fI(*func)(void)\fP, int \fIargc\fP, ...)
10 int swapcontext(ucontext\_t *\fIoucp\fP, const ucontext\_t *\fIucp\fP)
20 together form a set of functions that allow user-level context switching between multiple threads of control within a process.
24 function modifies the user thread pointed to by
26 to continue execution by invoking function
28 and passing that function a number of
30 integer arguments. The value of
32 must match the number of integer arguments passed to
34 , otherwise the behavior is undefined. Context
36 must have been initialized by a call to
38 and have a stack allocated for it. The address of the stack must be assigned to \fIucp\->uc_stack.ss_size\fP and the size of the stack to \fIucp\->uc_stack.ss_size\fP. The \fIucp\->uc_link\fP member is used to determine which successor context is run after the context modified by
40 returns. If left NULL, the process exits.
44 function saves the current context in the context structure pointed to by
46 and sets the context to the context structure pointed to by \fIucp\fP.
51 returns 0. Otherwise, -1 is returned and
53 is set to indicate the error. Note that a succesful call to
55 actually does not return. Only after returning to the context that called
64 Either the \fIucp\fP or \fIoucp\fP is a NULL pointer.
67 The context is not properly initialized.
70 The \fIucp\fP argument does not have enough stack left to complete the operation.