Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/times.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/times.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/times.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/times.html on line 8

times()

Get time-accounting information

Synopsis:

#include <sys/times.h>

clock_t times( struct tms* buffer );

Arguments:

buffer
A pointer to a tms structure where the function can store the time-accounting information. For information about the tms structure, see below.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The times() function stores time-accounting information in the structure pointed to by buffer. The type clock_t and the tms structure are defined in the <sys/times.h> header file.

The tms structure contains at least the following members:

clock_t tms_utime
The CPU time charged for the execution of user instructions of the calling process.
clock_t tms_stime
The CPU time charged for execution by the system on behalf of the calling process.
clock_t tms_cutime
The sum of the tms_utime and tms_cutime values of the child processes.
clock_t tms_cstime
The sum of the tms_stime and tms_cstime values of the child processes.

All times are in CLK_TCK'ths of a second. CLK_TCK is defined in the <time.h> header file. A CLK_TCK is the equivalent of:

#define sysconf( _SC_CLK_TCK )

The times of a terminated child process are included in the tms_cutime and tms_cstime elements of the parent when a wait() or waitpid() function returns the process ID of this terminated child. If a child process hasn't waited for its terminated children, their times aren't included in its times.

Returns:

The elapsed real time, in clock ticks, of kernel uptime.


Note: The value returned may overflow the possible range of type clock_t.

Examples:

/*
 * The following program executes the program
 * specified by argv[1].  After the child program
 * is finished, the cpu statistics of the child are
 * printed.
 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/times.h>

int main( int argc, char **argv )
  {
    struct tms childtim;

    system( argv[1] );
    times( &childtim );
    printf( "system time = %d\n", childtim.tms_cstime );
    printf( "user time   = %d\n", childtim.tms_cutime );
    return EXIT_SUCCESS;
  }

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

clock_gettime()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/times.html on line 202

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/times.html on line 202