# <sys/times.h>
>
>
> Include the system header <sys/times.h> to define the tms structure
> and the times function prototype.
>
>
> struct tms {
>
>
> clock\_t tms\_utime; clock\_t tms\_stime; clock\_t tms\_cutime; clock\_t
> tms\_cstime;
>
>
> };
>
>
> clock\_t times(struct tms \*buffer); [POSIX]
>
>
> times
>
>
> clock\_t times(struct tms \*buffer); [POSIX]
>
>
> This interface is obsoleted by gettimeofday.
The times function returns the value of time in clock ticks since 0
hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal Time
(UTC).
The number of clock ticks per second can be determined by calling
sysconf with the
\_SC\_CLK\_TCK request. It is typically (but not always) between 60 and
1024.
At the common rate of 100 ticks per second on many NetBSD ports and with
a 32-bit unsigned clock\_t, this value first wrapped in 1971.
The times call also fills in the structure pointed to by buffer with
time accounting information. [Table 11-9](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_posix_sys-times.html#_bookmark679) 10-9 lists
the elements of the tms structure.
>
>
> **Table 11-9 tms structure elements**
| **Element** | **Description** |
| --- | --- |
| tms\_utime | The CPU time charged for the execution of user instructions. |
| tms\_stime | - The CPU time charged for execution by the system on behalf of
- the process. |
| tms\_cutime | - The sum of the tms\_utime s and tms\_cutime s of the child
- processes. |
| tms\_cstime | - The sum of the tms\_stimes and tms\_cstimes of the child
- processes. |
All times are measured in clock ticks, as defined above. At 100 ticks
per second, and with a 32-bit unsigned clock\_t, the values wrap after
497 days.
The times of a terminated child process are included in the tms\_cutime
and tms\_cstime elements of the parent when one of the wait functions
returns the process ID of the terminated child to the parent. If an
error occurs, times returns the value ((clock\_t)-1), and sets errno to
indicate the error.
Last Published: Oct 06, 2026
Previous Topic
Next Topic