itimer(7) —
NAME
itimer − interval timer pseudo device driver
SYNOPSIS
#include <sys/itimer.h>
#include <sys/time.h>
DESCRIPTION
itimer is an interval timer pseudo device driver that emulates the equivalent of the BSD interval timers for the real and virtual timer on the INTERACTIVE UNIX System. Use the open(2) system call to open the /dev/itimer pseudo device driver, and use the ioctl(2) system call to set or get the real or virtual timer.
Ioctl Calls
SETITIMER or GETITIMER, defined in /usr/include/sys/itimer.h, are used to set or get the real or virtual timer and are used as the second argument of the ioctl(2) system call.
SETITIMER | ITIMER_REAL sets the real timer.
SETITIMER | ITIMER_VIRTUAL sets the virtual timer.
GETITIMER | ITIMER_REAL gets the real timer.
GETITIMER | ITIMER_VIRTUAL gets the virtual timer.
The third argument of the ioctl(2) system call specifies the timer value, and it must be a pointer to an itimerval structure:
struct itimerval{
struct timeval it_interval; /* timer interval */
struct timeval it_value/* current value */
};
If it_value is non-zero, it indicates the time to the next timer expiration. If it_interval is non-zero, it specifies a value to be used in reloading it_value when the timer expires. Setting it_value to 0 disables the timer. Setting it_interval to 0 causes the timer to be disabled after its next expiration (assuming it_value is non-zero). Time values smaller than the system clock’s resolution are rounded up to the smallest clock resolution on the system.
The ITIMER_REAL timer decrements in real time. A SIGALRM signal is delivered when this time expires.
The ITIMER_VIRTUAL timer decrements in process virtual time. It runs only when the process is executing. A SIGVTALRM signal is delivered when it expires. SIGVTALARM and SIGUSR2 are the same signal.
NOTES
This pseudo device driver allows only one type of timer per device to be open (for example, you can not issue the command SETITIMER | ITIMER_REAL | ITIMER_VIRTUAL via ioctl system call).
ITIMER_PROF is not yet implemented.
After returning from an ioctl call with SETITIMER, the itimerval structure will be set to the remaining time left before expiration.
The total number of interval timers that can be active at the same time on a system is 24.
RETURN VALUE
If the call succeeds, a value of 0 is returned, otherwise a value of -1 is returned and errno is set to the proper error number.
ADDED VALUE
This entry, supplied by SunSoft, Inc., is an extension of UNIX System V.
\*U — Version 1.0