set the current time of a clock
#include <time.h> int qnx_setclock( pid_t proc_pid, clockid_t clock_id, struct timespec *tp );
The qnx_setclock() function sets the current time of the clock of type clock_id from the buffer pointed to by tp on the node identified by proc_pid. If proc_pid is zero, the current node is used.
To set the time on another node, proc_pid should be passed as a virtual circuit to the process manager on that node. For example,
/* Attach a vc to the process manager on node 4 */ proc_pid = qnx_vc_attach( 4, PROC_PID, 0, 0 );
The only supported clock type is CLOCK_REALTIME.
The tp parameter points to a structure containing the following:
/* * This program synchronizes the system clock of the * node address(s) provided as arguments with the * system clock of the node it is running on. */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/vc.h> #include <sys/kernel.h> void main( int argc, char **argv ) { nid_t node; pid_t procpid; struct timespec gtime; int i; for( i = 1; i < argc; i++ ) { node = strtol( argv[i], NULL, 0 ); if( ( procpid = qnx_vc_attach( node, PROC_PID, 0, _VC_AT_SHARE ) ) == -1 ) { perror( "qnx_vc_attach" ); fprintf( stderr, "Can't attach to node %ld\n", node ); continue; } if( qnx_getclock( PROC_PID, CLOCK_REALTIME, >ime ) == 0 ) { if( qnx_setclock( procpid, CLOCK_REALTIME, >ime ) == -1 ) { perror( "qnx_setclock" ); fprintf( stderr, "Can't set time on node %ld\n", node ); } } else { perror( "qnx_getclock" ); } qnx_vc_detach( procpid ); } exit( 0 ); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
errno, clock_gettime(), clock_setres(), clock_settime(), qnx_vc_attach()