CLOCK_GETCPUCLOCKID2(2) System Calls Manual CLOCK_GETCPUCLOCKID2(2)

clock_getcpuclockid2, clock_getcpuclockid
retrieve the clock id of a process or LWP

Standard C Library (libc, -lc)

#include <time.h>

int
clock_getcpuclockid2(idtype_t idtype, id_t id, clockid_t *clock_id);

int
clock_getcpuclockid(pid_t pid, clockid_t *clock_id);

The cpu_getcpuclockid2() function retrieves the clock_id for the CPU-time clock of the specified id and idtype. Supported idtypes are:
The specified process id or 0 for the current process.
The specified LWP id or 0 for the current LWP.

The clock_getcpuclockid() function is equivalent to calling clock_getcpuclockid2() with idtype P_PID and id pid.

The clock_gettime(2) function can be used with the returned clock_id to retrieve process and LWP CPU usage times.

The clock_getcpuclockid2() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

If successful, the clock_getcpuclockid() function will return 0. Otherwise an error number will be returned.

These functions fail if:
[]
clock_id points outside the process's allocated address space.

In addition clock_getcpuclockid2() will fail if:

[]
An unsupported idtype was supplied.

clock_gettime(2)

The clock_getcpuclockid() function conforms to IEEE Std 1003.1-2001 (“POSIX.1”). The clock_getcpuclockid2() is a NetBSD extension.

The clock_getcpuclockid() and clock_getcpuclockid2() functions appeared in NetBSD 8.
June 24, 2018 NetBSD 9.2