clocks.2 (2010 09)

c
clocks(2) clocks(2)
NAME
clock_settime(), clock_gettime(), clock_getres() - clock operations
SYNOPSIS
#include <time.h>
int clock_settime(
clockid_t clock_id,
const struct timespec *tp);
int clock_gettime(
clockid_t clock_id,
struct timespec *tp);
int clock_getres(
clockid_t clock_id,
struct timespec *res);
DESCRIPTION
clock_settime()
The clock_settime()
function sets the specified clock, clock_id
, to the value specified by tp.
Time values that are between two consecutive non-negative integer multiples of the resolution of the
specified clock are truncated down to the smaller multiple of the resolution.
clock_gettime()
The
clock_gettime() function returns the current value
tp for the specified clock, clock_id.
clock_getres()
The resolution of any clock can be obtained by calling
clock_getres()
. Clock resolutions are imple-
mentation defined and are not settable by a process. If the argument
res is not NULL, the resolution of
the specified clock is stored into the location pointed to by res.Ifres
is NULL, the clock resolution is
not returned.
A clock may be system wide, that is, visible to all processes; or per-process, measuring time that is mean-
ingful only within a process.
The following clocks are supported:
CLOCK_REALTIME
This clock represents the realtime clock for the system. For this clock, the values
returned by clock_gettime()
and specified by clock_settime() represent the
amount of time (in seconds and nanoseconds) since the Epoch. It is a system wide
clock. The
SYSATTR privilege is required to set this clock. Processes owned by the
superuser have this privilege. Processes owned by other users may have this privilege,
depending on system configuration. See privileges (5) for more information about
privileged access on systems that support fine-grained privileges.
CLOCK_VIRTUAL
This clock represents the amount of time (in seconds and nanoseconds) that the calling
process has spent executing code in the user’s context. It is a per-process clock. It can-
not be set by the user.
CLOCK_PROFILE
This clock represents the amount of time (in seconds and nanoseconds) that the calling
process has spent executing code in both the user’s context and in the operating system
on behalf of the calling process. It is a per-process clock. It cannot be set by the user.
RTTIMER0 RTTIMER1
These clocks are high resolution hardware clocks present on HP-RT realtime systems.
It is included here so that applications accessing this hardware can be compiled on
HP-UX systems and then ported to an HP-RT target. HP-UX does not support RTTI-
MER0 or RTTIMER1.
RETURN VALUE
A return of zero indicates that the call succeeded. A return value of 1 indicates that an error occurred,
and
errno is set to indicate the error.
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)