73 lines
2.7 KiB
Plaintext
73 lines
2.7 KiB
Plaintext
'\"macro stdmacro
|
|
.if n .pH g3c.makecontext @(#)makecontext 40.21 of 1/3/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} makecontext 3C "" "\&"
|
|
.if \nX=1 .ds x} makecontext 3C ""
|
|
.if \nX=2 .ds x} makecontext 3C "" "\&"
|
|
.if \nX=3 .ds x} makecontext "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4makecontext\f1, \f4swapcontext\f1 \- manipulate user contexts
|
|
.SH SYNOPSIS
|
|
\f4#include <ucontext.h>\f1
|
|
.PP
|
|
\f4void makecontext (ucontext_t \(**\f2ucp\fP, (void(\(**)())\f2func\fP, int \f2argc\fP,...);\f1
|
|
.PP
|
|
\f4int swapcontext (ucontext_t \(**\f2oucp\fP, ucontext_t \(**\f2ucp\fP);\f1
|
|
.SH DESCRIPTION
|
|
.PP
|
|
These functions are useful for implementing user-level context switching
|
|
between multiple threads of control within a process.
|
|
.PP
|
|
\f4makecontext\fP modifies the context specified by \f2ucp\fP,
|
|
which has been initialized using \f4getcontext\fP; when this
|
|
context is resumed using \f4swapcontext\fP or \f4setcontext\fP
|
|
[see \f4getcontext\fP(2)], program execution continues by
|
|
calling the function \f2func\fP, passing it the arguments
|
|
that follow \f2argc\fP in the
|
|
\f4makecontext\fP call.
|
|
Before a call is made to \f4makecontext\fP, the context being modified
|
|
should have a stack allocated for it.
|
|
The integer value of \f2argc\f1 must match
|
|
the number of arguments that follow \f2argc\f1.
|
|
\%Otherwise the behavior is undefined.
|
|
.P
|
|
The \f4uc_link\fP field is used to determine the context that will be
|
|
resumed when the context being modified by \f4makecontext\fP returns.
|
|
The \f4uc_link\fP field should be initialized prior to the call to
|
|
\f4makecontext\fP.
|
|
.PP
|
|
\f4swapcontext\fP
|
|
saves the current context in the context structure pointed to by
|
|
.IR oucp\^
|
|
and sets the context to the context structure pointed to by
|
|
.IR ucp .
|
|
.PP
|
|
These functions will fail if either of the following is true:
|
|
.TP 15
|
|
\f4ENOMEM\fP
|
|
\f2ucp\f1 does not have enough stack left to complete the operation.
|
|
.TP
|
|
\f4EFAULT\fP
|
|
\f2ucp\f1 or \f2oucp\f1 points to an invalid address.
|
|
.SH "SEE ALSO"
|
|
\f4exit\fP(2), \f4getcontext\fP(2), \f4sigaction\fP(2), \f4sigprocmask\fP(2), \f4ucontext\fP(5).
|
|
.SH "DIAGNOSTICS"
|
|
On successful completion, \f4swapcontext\f1 return a value of zero.
|
|
Otherwise, a value of \-1 is returned and \f4errno\f1 is set to
|
|
indicate the error.
|
|
.SH BUGS
|
|
Due to the procedure calling conventions on the MIPS processor and restrictions
|
|
of \f4stdarg\fP(5), the arguments that follow the \f2argc\fP parameter for
|
|
\f4makecontext\fP are restricted to longs and pointers only.
|
|
.SH NOTES
|
|
The size of the
|
|
\f4ucontext_t\fP
|
|
structure may change in future releases. To remain binary compatible,
|
|
users of these features must always use \f4makecontext\fP or \f4getcontext\fP to
|
|
create new instances of them.
|
|
.\" @(#)makecontext.3c 40.6 of 9/27/88
|
|
.Ee
|