Table of Contents

Name

fasttime_init, fasttime_init_context - initialise the fasttime library

Synopsis

#include <fasttime.h>

int fasttime_init();

int fasttime_init_context(fasttime_context_t context, int method);

Description

One of these functions must be called before making any other fasttime calls. Most applications can simply call the no-argument variant, which is equivalent to:

fasttime_init_context(NULL, FASTTIME_METHOD_BEST);

context must have been allocated with fasttime_create_context, or pass NULL to use a default, static context.

method is a set of flags bitwise OR'd together that give the allowable methods. The methods are:

FASTTIME_METHOD_DAEMON
Use the calibration tables provided from a running fasttimed process
FASTTIME_METHOD_CLIENT
Start a thread within this process that maintains calibration tables. The thread will run for the duration of the process.
FASTTIME_METHOD_SYSTEM
Pass calls directly to gettimeofday(2)
FASTTIME_METHOD_BEST
All of the above (the default).

Return Values

Both functions return the actual method that will be used, or -1 if none of the requested methods are available (in which case init has failed).

Examples

Initialise the static context with default options (uses the best available method):

fasttime_init();

Ensure the system call pass-through is not used:

fasttime_init_context(NULL, FASTTIME_METHOD_DAEMON | FASTTIME_METHOD_CLIENT);

Thread Safety

Neither of these functions are thread-safe; calls to this function should be synchronised with all other fasttime library calls.

Note that either of these calls may create a new thread if FASTTIME_METHOD_CLIENT was specified; this thread can be terminated by destroying the context.

Known Issues

Applications should not create more than one context with FASTTIME_METHOD_CLIENT in the same process, as they will interfere with each other.

Author

Alex Holkner (alex@partiallydisassembled.net)

Homepage

http://fasttime.sourceforge.net/

See Also

fasttime_create_context(3) fasttime_gettimeofday(3) fasttime_getticks(3) fasttime_statistics(3) fasttimed(8)


Table of Contents