Manipulates the expiration time of interval timers.
#include <sys/time.h> int getinterval (TimerID, Value) timer_t TimerID; struct itimerstruc_t *Value; int incinterval (TimerID, Value, OValue) timer_t TimerID; struct itimerstruc_t *Value, *OValue; int absinterval (TimerID, Value, OValue) timer_t TimerID; struct itimerstruc_t *Value, *OValue; int resabs (TimerID, Resolution, Maximum) timer_t TimerID; struct timestruc_t *Resolution, *Maximum; int resinc (TimerID, Resolution, Maximum) timer_t TimerID; struct timestruc_t *Resolution, *Maximum;
#include <unistd.h>
unsigned int alarm (Seconds) unsigned int Seconds; useconds_t ualarm (Value, Interval) useconds_t Value, Interval; int setitimer (Which, Value, OValue) int Which; struct itimerval *Value, *OValue; int getitimer (Which, Value) int Which; struct itimerval *Value;
The getinterval, incinterval, and absinterval subroutines manipulate the expiration time of interval timers. These functions use a timer value defined by the struct itimerstruc_t structure, which includes the following fields:
struct timestruc_t it_interval; /* timer interval period */ struct timestruc_t it_value; /* timer interval expiration */
If the it_value field is nonzero, it indicates the time to the next timer expiration. If it_value is 0, the per-process timer is disabled. If the it_interval member is nonzero, it specifies a value to be used in reloading the it_value field when the timer expires. If it_interval is 0, the timer is to be disabled after its next expiration (assuming it_value is nonzero).
The getinterval subroutine returns a value from the struct itimerstruc_t structure to the Value parameter. The it_value field of this structure represents the amount of time in the current interval before the timer expires, should one exist for the per-process timer specified in the TimerID parameter. The it_interval field has the value last set by the incinterval or absinterval subroutine. The fields of the Value parameter are subject to the resolution of the timer.
The incinterval subroutine sets the value of a per-process timer to a given offset from the current timer setting. The absinterval subroutine sets the value of the per-process timer to a given absolute value. If the specified absolute time has already expired, the absinterval subroutine will succeed and the expiration notification will be made. Both subroutines update the interval timer period. Time values smaller than the resolution of the specified timer are rounded up to this resolution. Time values larger than the maximum value of the specified timer are rounded down to the maximum value.
The resinc and resabs subroutines return the resolution and maximum value of the interval timer contained in the TimerID parameter. The resolution of the interval timer is contained in the Resolution parameter, and the maximum value is contained in the Maximum parameter. These values might not be the same as the values returned by the corresponding system timer, the gettimer subroutine. In addition, it is likely that the maximum values returned by the resinc and resabs subroutines will be different.
Note: If a nonprivileged user attempts to submit a fine granularity timer (that is, a timer request of less than 10 milliseconds), the timer request is raised to 10 milliseconds.
The alarm subroutine causes the system to send the calling thread's process a SIGALRM signal after the number of real-time seconds specified by the Seconds parameter have elapsed. Since the signal is sent to the process, in a multi-threaded process another thread than the one that called the alarm subroutine may receive the SIGALRM signal. Processor scheduling delays may prevent the process from handling the signal as soon as it is generated. If the value of the Seconds parameter is 0, a pending alarm request, if any, is canceled. Alarm requests are not stacked. Only one SIGALRM generation can be scheduled in this manner. If the SIGALRM signal has not yet been generated, the call results in rescheduling the time at which the SIGALRM signal is generated. If several threads in a process call the alarm subroutine, only the last call will be effective.
The ualarm subroutine sends a SIGALRM signal to the invoking process in a specified number of seconds. The getitimer subroutine gets the value of an interval timer. The setitimer subroutine sets the value of an interval timer.
If these subroutines are successful, a value of 0 is returned. If an error occurs, a value of -1 is returned and the errno global variable is set.
The alarm subroutine returns the amount of time (in seconds) remaining before the system is scheduled to generate the SIGALARM signal from the previous call to alarm. It returns a 0 if there was no previous alarm request.
The ualarm subroutine returns the number of microseconds previously remaining in the alarm clock.
If the getinterval, incinterval, absinterval, resinc, resabs, setitimer, getitimer, or setitimer subroutine is unsuccessful , a value of -1 is returned and the errno global variable is set to one of the following error codes:
The alarm subroutine is always successful. No return value is reserved to indicate an error for it.
These subroutines are part of Base Operating System (BOS) Runtime.
The gettimer subroutine, gettimerid subroutine, sigaction, sigvec, or signal subroutine.
List of Time Data Manipulation Services, Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.
Signal Management in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs provides more information about signal management in multi-threaded processes.