[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts

Using Fine Granularity Timer Services and Structures

The tstart, tfree, talloc, and tstop services provide fine-resolution timing functions. These timer services should be used when the following conditions are required:

The Watchdog timer services can be used for noncritical times having a one-second resolution. The timeout service can be used for noncritical times having a clock-tick resolution.

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 itimerstruc_t t.it value substructure should be 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. It should be ORed into the t ->flag field if an absolute timer request is desired.

The T_LOWRES flag causes the system to round the t ->timeout value to the next timer timeout. It should be ORed into the t ->flags field. The timeout is always rounded to a larger value. Since the system maintains 10ms interval timer, T_LOWRES will never cause more than 10ms to be added to a timeout. The advantage of using T_LOWRES is that it prevents an extra interrupt from being generated.

The t ->timeout and t ->flags fields must be set or reset before each call to the tstart kernel service.

Coding the Timer Function .

The t ->func timer function should be declared as follows:

void func (t)
struct trb *t;

The argument to the func completion handler routine is the address of the trb structure, not the contents of the t_union field.

The t ->func timer function is called on an interrupt level. Therefore, code for this routine must follow conventions for interrupt handlers.

Related Information

Understanding Interrupts.

Timer and Time-of-Day Kernel Services.

The tstart kernel service, tstop kernel service, talloc kernel service, tfree kernel service.

[ Previous | Next | Contents | Home | Search ]