Displays information about resource use.
getrusage, getrusage64, times: Standard C Library (libc.a)
Item | Description |
---|---|
vtimes: | Berkeley Compatibility Library (libbsd.a) |
#include <sys/times.h>
#include <sys/resource.h>
int getrusage ( Who, RUsage)
int Who;
struct rusage *RUsage;
int getrusage64 ( Who, RUsage)
int Who;
struct rusage64 *RUsage;
#include <sys/types.h>
#include <sys/times.h>
clock_t times ( Buffer)
struct tms *Buffer;
#include <sys/times.h>
vtimes ( ParentVM, ChildVM)
struct vtimes *ParentVm, ChildVm;
The getrusage subroutine displays information about how resources are used by the current process or all completed child processes.
When compiled in 64-bit mode, rusage counters are 64 bits. If getrusage is compiled in 32-bit mode, rusage counters are 32 bits. If the kernel's value of a usage counter has exceeded the capacity of the corresponding 32-bit rusage value being returned, the rusage value is set to INT_MAX.
The getrusage64 subroutine can be called to make 64-bit rusage counters explicitly available in a 32-bit environment.
In AIX® 5.1 and later, 64-bit quantities are also available to 64-bit applications through the getrusage() interface in the ru_utime and ru_stime fields of struct rusage.
The times subroutine fills the structure pointed to by the Buffer parameter with time-accounting information. All time values reported by the times subroutine are measured in terms of the number of clock ticks used. Applications should use sysconf (_SC_CLK_TCK) to determine the number of clock ticks per second.
The tms structure defined in the /usr/include/sys/times.h file contains the following fields:
time_t tms_utime;
time_t tms_stime;
time_t tms_cutime;
time_t tms_cstime;
This information is read from the calling process as well as from each completed child process for which the calling process executed a wait subroutine.
Item | Description |
---|---|
tms_utime | The CPU time used for executing instructions in the user space of the calling process |
tms_stime | The CPU time used by the system on behalf of the calling process. |
tms_cutime | The sum of the tms_utime and the tms_cutime values for all the child processes. |
tms_cstime | The sum of the tms_stime and the tms_cstime values for all the child processes. |
The vtimes subroutine is supported to provide compatibility with earlier programs.
The vtimes subroutine returns accounting information for the current process and for the completed child processes of the current process. Either the ParentVm parameter, the ChildVm parameter, or both may be 0. In that case, only the information for the nonzero pointers is returned.
After a call to the vtimes subroutine, each buffer contains information as defined by the contents of the /usr/include/sys/vtimes.h file.
Item | Description |
---|---|
Who | Specifies a value of RUSAGE_THREAD, RUSAGE_SELF, or RUSAGE_CHILDREN. |
RUsage | Points to a buffer described in the /usr/include/sys/resource.h
file. The fields are interpreted as follows:
|
Buffer | Points to a tms structure. |
ParentVm | Points to a vtimes structure that contains the accounting information for the current process. |
ChildVm | Points to a vtimes structure that contains the accounting information for the terminated child processes of the current process. |
Upon successful completion, the getrusage and getrusage64 subroutines return a value of 0. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
Upon successful completion, the times subroutine returns the elapsed real time in units of ticks, whether profiling is enabled or disabled. This reference time does not change from one call of the times subroutine to another. If the times subroutine fails, it returns a value of -1 and sets the errno global variable to indicate the error.
Item | Description |
---|---|
EINVAL | The Who parameter is not a valid value. |
EFAULT | The address specified for RUsage is not valid. |
Item | Description |
---|---|
EFAULT | The address specified by the buffer parameter is not valid. |