.\" Copyright (c) 1980, 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getpriority.2 6.9 (Berkeley) 3/10/91 .\" .\" Modified Sat Jul 24 16:33:19 1993 by Rik Faith .\" Modified Mon Jul 1 21:59:57 1996 by Andries Brouwer .\" Modified Wed Nov 6 03:55:47 1996 by Eric S. Raymond .\" Modified, 21 Oct 01, Michael Kerrisk, .\" Corrected statement under EPERM to clarify privileges required .\" Modified, 21 Jun 02, Michael Kerrisk, .\" Clarified meaning of 0 value for 'who' argument .\" .TH GETPRIORITY 2 "21 junio 2002" "Página de Manual BSD" "Manual del Programador de Linux" .SH NOMBRE getpriority, setpriority \- obtiene/asigna la prioridad de planificación de un programa .SH SINOPSIS .B #include .br .B #include .sp .BI "int getpriority(int " which ", int " who ); .br .BI "int setpriority(int " which ", int " who ", int " prio ); .SH DESCRIPCIÓN La prioridad de planificación del proceso, grupo de procesos o usuario, según se indique en .I which y .I who se obtiene con la función .B getpriority y se asigna con .B setpriority. .I Which puede ser .BR PRIO_PROCESS , .BR PRIO_PGRP , o .BR PRIO_USER , y .I who se interpreta en función de .I which (un indentificador de proceso para .BR PRIO_PROCESS , un indentificador de grupo de procesos para .BR PRIO_PGRP , y un identificador de usuario para .BR PRIO_USER ). Un valor cero de .I who indica (respectivamente) el proceso invocador, el grupo de proceso del proceso invocador, o el identificador de usuario real del proceso invocador. .I Prio es un valor que puede variar de \-20 a 20 (vea la sección Observaciones más abajo) . La prioridad por defecto es 0; cuanto más baja es la prioridad más favorable es la planificación. La llamada .B getpriority devuelve la prioridad más alta (el valor numérico más bajo) de la que disfruta cualquiera de los procesos especificados. La llamada .B setpriority asigna el valor especificado a las prioridades de todos los procesos especificados. Sólo el superusuario puede decrementar las prioridades (haciéndolas, por tanto, más altas). .SH "VALOR DEVUELTO" Ya que .B getpriority legítimamente puede devolver el valor \-1, es necesario borrar la variable externa .I errno antes de la llamada a la función y comprobar su valor más adelante para determinar si \-1 es un error o un valor legítimo. La función .B setpriority devuelve 0 si no hay error o \-1 si lo hay. .SH ERRORES .TP 0.8i .B ESRCH No se encontró ningún proceso que cumpliera con los valores especificados por .I which y .I who. .TP .B EINVAL .I Which no era .BR PRIO_PROCESS , .BR PRIO_PGRP , ni .BR PRIO_USER . .PP Además de los errores indicados arriba, .B setpriority puede fallar si: .TP .B EPERM Se encontró un proceso, pero ni el identificador de usuario efectivo ni el identificador de usuario real del invocador coinciden con su identificador de usuario efectivo. .TP .B EACCES Un no superusuario intentó decrementar la prioridad de un proceso. .SH OBSERVACIONES Los detalles sobre la condición para EPERM dependen del sistema. La descripción dada arriba es lo que dice SUSv3, y parece ser seguida por todos los sistemas de tipo SYSV. Linux requiere que el identificador de usuario real o efectivo del invocador coincida con el usuario real del proceso \fIwho\fP (en lugar de su identificador de usuario efectivo). Todos los sistemas de tipo BSD (SunOS 4.1.3, Ultrix 4.2, BSD 4.3, FreeBSD 4.3, OpenBSD-2.5, ...) requieren que el identificador de usuario efectivo del invocador coincida con el identificador de usuario real o efectivo del proceso \fIwho\fP. .LP El rango real de prioridad varía entre las diferentes versiones del núcleo. Las versiones de Linux anteriores a la 1.3.36 tenían -infinito..15. A partir de la versión 1.3.43 se tiene -20..19, y la llamada al sistema getpriority devuelve 40..1 para estos valores (puesto que los números negativos son códigos de error). La llamada de biblioteca convierte N a 20-N. .LP Incluir .I no es obligatorio hoy día, pero incrementa la portabilidad. (De hecho, .I define la estructura .I rusage con campos de tipo .I struct timeval definida en .IR .) .SH CONFORME A SVr4, 4.4BSD (estas funciones aparecieron por primera vez en 4.2BSD). .SH "VÉASE TAMBIÉN" .BR nice (1), .BR fork (2), .BR renice (8)