Allocates a per-process interval timer.
Standard C Library (libc.a)
#include <sys/time.h>
#include <sys/events.h>
timer_t gettimerid( timertype, notifytype)
int timertype;
int notifytype;
The gettimerid subroutine is used to allocate a per-process interval timer based on the timer with the given timer type. The unique ID is used to identify the interval timer in interval timer requests. (For more information, see getinterval subroutine). The particular timer type, the timertype parameter, is defined in the sys/time.h file and can identify either a system-wide timer or a per-process timer. The mechanism by which the process is to be notified of the expiration of the timer event is the notifytype parameter, which is defined in the sys/events.h file.
The timertype parameter represents one of the following timer types:
Item | Description |
---|---|
TIMEOFDAY | POSIX system clock timer. This timer represents the time-of-day clock for the system. For this timer, the values returned by the gettimer subroutine and specified by the settimer subroutine represent the amount of time since 00:00:00 GMT, January 1, 1970, in nanoseconds. |
TIMERID_ALRM | Alarm timer. This timer schedules the delivery of a SIGALRM signal at a timer specified in the call to the settimer subroutine. |
TIMERID_REAL | Real-time timer. The real-time timer decrements in real time. A SIGALRM signal is delivered when this timer expires. |
TIMERID_REAL_TH | Real-time, per-thread timer. Decrements in real time and delivers a SIGTALRM signal when it expires. The SIGTALRM is sent to the thread that sets the timer. Each thread has its own timer and can manipulate its own timer. This timer is only supported with the 1:1 thread model. If the timer is used in M:N thread model, undefined results might occur. |
TIMERID_VIRTUAL | Virtual timer. The virtual timer decrements in process virtual time. it runs only when the process is executing in user mode. A SIGVTALRM signal is delivered when it expires. |
TIMERID_PROF | Profiling timer. The profiling timer decrements both when running in user mode and when the system is running for the process. It is designed to be used by processes to profile their execution statistically. A SIGPROF signal is delivered when the profiling timer expires. |
Interval timers with a notification value of DELIVERY_SIGNAL are inherited across an exec subroutine.
Item | Description |
---|---|
notifytype | Notifies the process of the expiration of the timer event. |
timertype | Identifies either a system-wide timer or a per-process timer. |
If the gettimerid subroutine succeeds, it returns a timer_t structure that can be passed to the per-process interval timer subroutines, such as the getinterval subroutine. If an error occurs, the value -1 is returned and errno is set.
If the gettimerid subroutine fails, the value -1 is returned and errno is set to one of the following error codes:
Item | Description |
---|---|
EAGAIN | The calling process has already allocated all of the interval timers associated with the specified timer type for this implementation. |
EINVAL | The specified timer type is not defined. |