HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

times

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Gets process times.

Syntax

   #include <sys/times.h>

   clock_t (struct tms *buffer);

Parameters

buffer

insert parameter info here

Return Values

Upon successful completion, times() will return the elapsed real time, in clock ticks, since and arbitrary point in the past (for example, system start-up time). This point does not change from one invocation of times() within the process to another. The return value may overflow the possible range of type clock_t. The times function fails, a value of (clock_t)-1 is returned and errno is set to indicate the error.

Description

The times() function will fill the structure pointed to by buffer with time-accounting information. The type clock_t and the tms structure are defined in <sys/times.h>; the tms structure will contain at least the following members:

Member TypeMember NameDescription
clock_ttms_utimeUser CPU time.
clock_ttms_stimeSystem CPU time.
clock_ttms_cutimeUser CPU time of terminated child processes.
clock_ttms_cstimeSystem CPU time of terminated child processes.

All times are measured in terms of the number of clock ticks used.

The times of a terminated child process are included in the tms_cutime and tms_cstime elements of the parent when a wait() or waidpid() function returns the process ID of this terminated child. See 3.2.1. If a child process has not waited for its terminated children, their times will not be included in its times.

The value tms_utime is the CPU time charged for the execution of user instructions.

The value tms_stime is the CPU time charged for execution by the system on behalf of the process.

The value tms_cstime is the sum of the tms_stimes and tms_cstimes fo the child processes.

Implementation Considerations

Because MPE/iX tracks the CPU time used by a process as a single total value, and does not distinguidsh between "user" and "system" CPU time, the information returned in the tms structure is based on estimated percentages of the total CPU time. The sum of the tms_utime and tms_stime fields will still reflect the total CPU time of the process. This is similar for the terminated child times calculation.

Errors

If an error occurs, errno is set to one of the following values:

EFAULTCAUSEThe system detected a NULL or bad pointer in attempting to use the buffer parameter.
 ACTIONMake sure that the pointer is correctly initialized.

See Also

exec(), fork(), sysconf(), time(), wait(), POSIX.1

Feedback to webmaster