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/clocktime.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/clocktime.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/clocktime.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/clocktime.html on line 8

ClockTime(), ClockTime_r()

Get or set a clock

Synopsis:

#include <sys/neutrino.h>

int ClockTime( clockid_t id,
               const uint64_t * new,
               uint64_t * old );

int ClockTime_r( clockid_t id,
                 const uint64_t * new,
                 uint64_t * old );

Arguments:

id
The clock ID. This must be CLOCK_REALTIME or CLOCK_MONOTONIC, which is the ID of the clock that maintains the system time, or the clock ID that's returned by ClockId().
new
NULL, or a pointer to the absolute time, in nanoseconds, to set the clock to. This is ignored when id is CLOCK_MONOTONIC.
old
NULL, or a pointer to a location where the function can store the current time (before being changed by a non-NULL new).

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

You can use these kernel calls to get or set the system clock specified by id. The clock ID, CLOCK_REALTIME or CLOCK_MONOTONIC, maintains the system time.

The ClockTime() and ClockTime_r() functions are identical except in the way they indicate errors. See the Returns section for details.


Note: Instead of using these kernel calls directly, consider calling clock_gettime() or clock_settime().

If new isn't NULL, then it contains the absolute time, in nanoseconds, to set the system clock to. This affects the software clock maintained by the system. It doesn't change any underlying hardware clock that maintains the time when the system's power is turned off.


Note: You can't set the time when the id is CLOCK_MONOTONIC.

Once set, the system time increments by some number of nanoseconds, based on the resolution of the system clock. You can query or change this resolution by using the ClockPeriod() kernel call.


Note: You need to have superuser privileges to set the clock.

Blocking states

These calls don't block.

Returns:

The only difference between these functions is the way they indicate errors:

ClockTime()
If an error occurs, the function returns -1 and sets errno. Any other value returned indicates success.
ClockTime_r()
EOK is returned on success. This function does NOT set errno. If an error occurs, the function returns a value in the Errors section.

Errors:

EFAULT
A fault occurred when the kernel tried to access the buffers provided.
EINVAL
The clock ID isn't CLOCK_REALTIME or CLOCK_MONOTONIC.
EPERM
The process tried to change the time without having superuser capabilities.
ESRCH
The process associated with this request doesn't exist.

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

clock_gettime(), clock_settime(), ClockAdjust(), ClockPeriod()

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/clocktime.html on line 241

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/clocktime.html on line 241