.\" Copyright (C) 2001 Andries Brouwer (aeb@cwi.nl) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Traducido por Miguel Pérez Ibars el 6-agosto-2004 .\" .TH MAKECONTEXT 3 "15 noviembre 2001" "Linux 2.4" "Manual del Programador de Linux" .SH NOMBRE makecontext, swapcontext \- manipulan el contexto de usuario .SH SINOPSIS .B #include .sp .BI "void makecontext(ucontext_t *" ucp ", void *" func "(), .BI "int " argc ", ...);" .br .BI "int swapcontext (ucontext_t *" oucp ", ucontext_t *" ucp ); .SH DESCRIPCIÓN En un entorno tipo SysV, se definen el tipo \fBucontext_t\fP en .I y las cuatro funciones \fBgetcontext()\fP, \fBsetcontext()\fP, \fBmakecontext()\fP y \fBswapcontext()\fP que permiten la conmutación del contexto del nivel de usuario entre múltiples hilos de control dentro de un proceso. .LP Para el tipo y las primeras dos funciones, véase .BR getcontext (2). .LP La función \fBmakecontext()\fP modifica el puntero apuntado por \fIucp\fP (que fue obtenido en una llamada previa a \fBgetcontext()\fP). Antes de llamar a \fBmakecontext()\fP, se debe reservar una nueva pila para este contexto, y asignarla a \fIucp->uc_stack\fP, y definir un contexto sucesor, y asignarlo a \fIucp->uc_link\fP. Cuando este contexto es activado más tarde (usando \fBsetcontext()\fP o \fBswapcontext()\fP) se llama en primer lugar a la función \fIfunc\fP, con los argumentos especificados después de \fIargc\fP (donde \fIargc\fP debe contener el número de estos argumentos), y cuando esta función regresa, el contexto sucesor es activado. Cuando el contexto sucesor es NULL , el hilo termina. .LP La función \fBswapcontext()\fP salva el contexto actual en la estructura apuntada por \fIoucp\fP, y activa el contexto apuntado por \fIucp\fP. .SH "VALOR DEVUELTO" Cuando tiene éxito, \fBmakecontext()\fP devuelve 0 y \fBswapcontext()\fP no regresa. (Pero puede regresar más tarde, en el caso de que \fIoucp\fP sea activado, en cuyo caso devuelve 0 como \fBswapcontext()\fP.) En caso de error, ambas devuelven \-1 y modifican \fIerrno\fP con el valor apropiado. .SH ERRORES .TP .B ENOMEM No queda suficiente espacio en la pila. .SH OBSERVACIONES La interpretación de \fIucp->uc_stack\fP es como en .BR sigaltstack (2), a saber, esta estructura contiene el comienzo y la longitud de un área de memoria a ser usada como pila, sea cual sea la dirección de crecimiento de la pila. Por lo tanto, no es necesario que los programas de usuario se preocupen por esta dirección. .SH "CONFORME A" SUSv2, POSIX 1003.1-2001. .SH "VÉASE TAMBIÉN" .BR getcontext (2), .BR sigaction (2), .BR sigaltstack (2), .BR sigprocmask (2), .BR sigsetjmp (3)