Get the resolution of the clock
#include <time.h> int clock_getres( clockid_t clock_id, struct timespec * res );
While the processor isn't in a power-saving mode, CLOCK_SOFTTIME behaves the same as CLOCK_REALTIME.
For more information about the different clocks, see Other clock sources in the Clocks, Timers, and Getting a Kick Every So Often of Getting Started with QNX Neutrino.
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The clock_getres() function gets the resolution of the clock specified by clock_id and puts it into the buffer pointed to by res.
/* * This program prints out the clock resolution. */ #include <stdio.h> #include <stdlib.h> #include <time.h> int main( void ) { struct timespec res; if ( clock_getres( CLOCK_REALTIME, &res) == -1 ) { perror( "clock get resolution" ); return EXIT_FAILURE; } printf( "Resolution is %ld micro seconds.\n", res.tv_nsec / 1000 ); return EXIT_SUCCESS; }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |