CLOCK_GETCPUCLOCKID2(2)

CLOCK_GETCPUCLOCKID2(2) | System Calls Manual | CLOCK_GETCPUCLOCKID2(2)

# NAME

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

# LIBRARY

Standard C Library (libc, -lc)

# SYNOPSIS

`#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);

# DESCRIPTION

The `cpu_getcpuclockid2`() function retrieves the clock_id for the CPU-time clock of the specified id and idtype. Supported idtypes are:

`P_PID`
  The specified process id or `0` for the current process.
`P_LWPID`
  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.

# RETURN VALUES

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.

# ERRORS

These functions fail if:

[`EFAULT`]
  clock_id points outside the process's allocated address space.

In addition `clock_getcpuclockid2`() will fail if:

[`EINVAL`]
  An unsupported idtype was supplied.

# SEE ALSO

clock_gettime(2)

# STANDARDS

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

# HISTORY

The `clock_getcpuclockid`() and `clock_getcpuclockid2`() functions appeared in NetBSD 8.

June 24, 2018 | NetBSD 9.4