Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/clock_getres.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/clock_getres.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/clock_getres.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/clock_getres.html on line 8
Get the resolution of the clock
#include <time.h>
int clock_getres( clockid_t clock_id,
struct timespec * res );
- clock_id
- The ID of the clock whose resolution you want to get.
- res
- A pointer to a
timespec
structure in which clock_getres() can store the resolution.
The function sets the tv_sec member to 0, and the
tv_nsec member to be the resolution of the clock, in nanoseconds.
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.
- 0
- Success
- -1
- An error occurred (errno is set).
- EFAULT
- A fault occurred trying to access the buffers provided.
- EINVAL
- Invalid clock_id.
/*
* 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;
}
POSIX 1003.1 TMR
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
clock_gettime(),
clock_settime(),
ClockPeriod(),
timespec
Clocks, Timers, and Getting a Kick Every So Often
chapter of Getting Started with QNX Neutrino
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/clock_getres.html on line 175
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/clock_getres.html on line 175