Time and timers

Time resolution

Time is stored in a RTIME which is defined as:

struct timespec {
typedef long long RTIME;
The main function to get time is rt_get_time(), which return the time measured in internal count units since start_rt_timer() function was called. Function rt_get_time_ns() is the same as rt_get_time but the returned time is converted to nanoseconds.

User timers

There is no user timers. There is only one timer handler per hardware timer, which is the associated with the interrupt handler. When the scheduler module is loaded, the scheduler takes the control of the timer and no other thread can use the timer.

The only timing facility that a thread can use being a periodic thread. And the delay functions: rt_busy_sleep(), rt_sleep() and rt_sleep_until(). Some functions use nanoseconds while other work with hardware ticks.

How time has to be used by the programmer is not well documented. The use of hardware ticks is very efficient, but produces different results when the same program runs on different hardware (for example, a i486 computer use the old 8254 clock while a Pentium has a builtin timer which provides a highest resolution clock).


The Watchdog module provide services to protect tasks (and the host Linux OS) against programming errors in RTAI applications. The watchdog can be programmed to perform several action on the occurrence of a task overrun.