Scroll to navigation

TIMES(2) Manual del Programador de Linux TIMES(2)

NOMBRE

times - obtiene los tiempos del proceso

SINOPSIS

#include <sys/times.h>
clock_t times(struct tms *buf);

DESCRIPCIÓN

times() almacena los tiempos del proceso en curso en la estructura tms a la que apunta buf. La estructura tms es tal como se define en <sys/times.h>:


struct tms {

clock_t tms_utime; /* tiempo de usuario */
clock_t tms_stime; /* tiempo de sistema */
clock_t tms_cutime; /* tiempo de usuario de los hijos */
clock_t tms_cstime; /* tiempo de sistema de los hijos */ };

El campo tms_utime contiene el tiempo de CPU empleado en la ejecución de instrucciones del proceso invocador. El campo tms_stime contiene el tiempo de CPU empleado en el sistema mientras se ejecutan tareas en nombre del proceso invocador.

El campo tms_cutime contiene la suma de los valores tms_utime y tms_cutime de todos los hijos terminados a los que se esperó. El campo tms_cstime contiene la suma de los valores tms_stime y tms_cstime de todos los hijos terminados a los que se esperó.

Los tiempos para los hijos terminados (y sus descendientes) son añadidos en el momento en el que wait(2) o waitpid(2) devuelve su identificador de proceso. En particular, los tiempos de los "nietos" a los que los hijos no esperaron no son procesados.

Todos los tiempos informados se dan en ticks de reloj.

VALOR DEVUELTO

times() returns the number of clock ticks that have elapsed since an arbitrary point in the past. The return value may overflow the possible range of type clock_t. On error, (clock_t) -1 is returned, and errno is set to indicate the error.

ERRORES

tms apunta fuera del espacio de direcciones asignado al proceso.

CONFORME A

POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.

NOTAS

El número de ticks de reloj por segundo puede obtenerse usando:


sysconf(_SC_CLK_TCK);

En POSIX.1-1996 el símbolo CLK_TCK (definido en <time.h>) se menciona como obsoleto. Está obsoleto en la actualidad.

In Linux kernel versions before 2.6.9, if the disposition of SIGCHLD is set to SIG_IGN, then the times of terminated children are automatically included in the tms_cstime and tms_cutime fields, although POSIX.1-2001 says that this should happen only if the calling process wait(2)s on its children. This nonconformance is rectified in Linux 2.6.9 and later.

On Linux, the buf argument can be specified as NULL, with the result that times() just returns a function result. However, POSIX does not specify this behavior, and most other UNIX implementations require a non-NULL value for buf.

Note that clock(3) also returns a value of type clock_t, but this value is measured in units of CLOCKS_PER_SEC, not the clock ticks used by times().

On Linux, the "arbitrary point in the past" from which the return value of times() is measured has varied across kernel versions. On Linux 2.4 and earlier, this point is the moment the system was booted. Since Linux 2.6, this point is (2^32/HZ) - 300 seconds before system boot time. This variability across kernel versions (and across UNIX implementations), combined with the fact that the returned value may overflow the range of clock_t, means that a portable application would be wise to avoid using this value. To measure changes in elapsed time, use clock_gettime(2) instead.

Histórico

SVr1-3 devuelve long y los miembros de la estructura son de tipo time_t aunque almacenan ticks de reloj, no segundos desde la época. V7 usaba long para los miembros de la estructura, porque no disponía del tipo time_t todavía.

ERRORES

A limitation of the Linux system call conventions on some architectures (notably i386) means that on Linux 2.6 there is a small time window (41 seconds) soon after boot when times() can return -1, falsely indicating that an error occurred. The same problem can occur when the return value wraps past the maximum value that can be stored in clock_t.

VÉASE TAMBIÉN

time(1), getrusage(2), wait(2), clock(3), sysconf(3), time(7)

COLOFÓN

Esta página es parte de la versión 5.13 del proyecto Linux man-pages. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en https://www.kernel.org/doc/man-pages/.

TRADUCCIÓN

La traducción al español de esta página del manual fue creada por Gerardo Aburruzaga García <gerardo.aburruzaga@uca.es> y Miguel Pérez Ibars <mpi79470@alu.um.es>

Esta traducción es documentación libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD.

Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a debian-l10n-spanish@lists.debian.org.

22 Marzo 2021 Linux