Timer Services Data Structures

The trb (timer request) structure is found in the /sys/timer.h file. The itimerstruc_t structure contains the second/nanosecond structure for time operations and is found in the sys/time.h file.

The trb structure contains a number of fields. Some of the fields are used for AIX® kernel processing. Others are intended for timer service users. A timer service user must set the following fields in the timer request block after calling the talloc service and before calling the tstart service.
Fields Description
t->flags Specifies the flags. You must set either the T_INCINTERVAL flag or the T_ABSOLUTE flag in the field. You can also set the T_LOWRES flag if you want. The T_LOWRES flag causes the system to round the t->timeout value to the next timer timeout. The advantage of using the T_LOWRES flag is that it prevents an extra timer interrupt from being generated. The timeout is rounded to a larger value. The T_LOWRES flag never causes more than 10 ms to be added to the timeout value because the system maintains timers at an interval of 10 ms.

You can set either the T_MOVE_OK or the T_LATE_OK flag to allow the system to perform optimizations with the timer. If the T_MOVE_OK flag is set, the system might move the timer to a different processor from where it was originally started. The T_MOVE_OK flag should be set when the you do not have a dependency on which processor the timer expires. If the T_LATE_OK flag is set, the timer expiration might be delayed when the owning processor is in a sleep state. The T_LATE_OK flag should be set if the T_MOVE_OK flag is not applicable and you can tolerate an arbitrarily late expiration. If both flags are set, the T_MOVE_OK flag has precedence over the T_LATE_OK flag.

After the T_MOVE_OK or T_LATE_OK flag is set, both flags persist until explicitly cleared by the owner.

Both flags are optional and are provided to aid internal system optimization.

t->timeout Specifies the timeout value. This field is used for both the interval timer and the absolute timer as indicated by the t->flags field.
t->func Specifies the completion-handler function pointer. This function must remain in pinned memory as long as the function might be called. Use the tstop service to cancel any pending timer request blocks that can call the completion handler before unloading the kernel extension containing the function.
t->ipri Specifies the interrupt priority at which the completion handler is called. Completion handlers are called in the interrupt environment. The interrupt priority values are defined in the /usr/include/sys/intr.h file. The least favored interrupt priority for a timer completion handler is INTTIMER. The most favored interrupt priority is INTMAX. For more information about interrupt priorities, see Understanding Interrupts in AIX® Version 6.1 Kernel Extensions and Device Support Programming Concepts.
t->t_union (optional) Passes data to the completion handler.
t->id (optional) Specifies the ID of the process that schedules the timer request block. Device drivers can set the field to a value of -1.
The t->func, t->t_union, t->ipri, and t->id fields persist across a call from tstart to the completion handler. Only the t->timeout and t->flags fields must be reset before a subsequent call to the tstart service.

Other fields in the trb structure do not need to be initialized between the talloc and tstart services.

The itimerstruc_t t.it value substructure is used to store time information for both absolute and incremental timers. The T_ABSOLUTE absolute request flag is defined in the sys/timer.h file.