#include <sys/time.h> int getitimer(int which, struct itimerval *value);
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue);
The system provides each process with four interval timers, defined in <sys/time.h>. The getitimer() function stores the current value of the timer specified by which into the structure pointed to by value. The setitimer() function call sets the value of the timer specified by which to the value specified in the structure pointed to by value, and if ovalue is not NULL, stores the previous value of the timer in the structure pointed to by ovalue.
A timer value is defined by the itimerval structure (see gettimeofday(3C)) for the definition of timeval), which includes the following members:
struct timeval it_interval; /* timer interval */ struct timeval it_value; /* current value */
The it_value member indicates the time to the next timer expiration. The it_interval member specifies a value to be used in reloading it_value when the timer expires. Setting it_value to 0 disables a timer, regardless of the value of it_interval. Setting it_interval to 0 disables a timer after its next expiration (assuming it_value is non-zero).
Time values smaller than the resolution of the system clock are rounded up to the resolution of the system clock, except for ITIMER_REALPROF, whose values are rounded up to the resolution of the profiling clock. The four timers are as follows:
si_tstamp; /* high resolution timestamp */ si_syscall; /* current syscall */ si_nsysarg; /* number of syscall arguments */ si_sysarg; /* actual syscall arguments */ si_fault; /* last fault type */ si_faddr; /* last fault address */ si_mstate; /* ticks in each microstate */
The enumeration of microstates (indices into si_mstate) is defined in <sys/msacct.h>.
Unlike the other interval timers, the ITIMER_REALPROF interval timer is not inherited across a call to one of the exec(2) family of functions.
Upon successful completion, 0 is returned. Otherwise, −1 is returned and errno is set to indicate the error.
The getitimer() and setitimer() functions will fail if:
See attributes(5) for descriptions of the following attributes:
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|
The ITIMER_PROF and ITIMER_REALPROF timers deliver the same signal and have different semantics. They cannot be used together.
The granularity of the resolution of alarm time is platform-dependent.
|June 15, 2009||OmniOS|