LinuxCNC Documentation
This page is 0% translated. Untranslated text is shown in English.

SYNTAX

long long rtapi_get_time();

DESCRIPTION

rtapi_get_time returns the current time in nanoseconds. Depending on the RTOS, this may be time since boot, or time since the clock period was set, or some other time. Its absolute value means nothing, but it is monotonically increasing and can be used to schedule future events, or to time the duration of some activity. Returns a 64 bit value. The resolution of the returned value may be as good as one nano-second, or as poor as several microseconds. May be called from init/cleanup code, and from within realtime tasks.

deltat = (long int)(end_time - start_time);

where end_time and start_time are longlong values returned from rtapi_get_time, and deltat is an ordinary long int (32 bits). This will work for times up to 2.1s. It is best used for millisecond and microsecond scale measurements though.

RETURN VALUE

Returns the current time in nanoseconds.

REALTIME CONSIDERATIONS

May be called from init/cleanup code and from within realtime tasks. Not available in non-realtime components.