ClockPeriod(), ClockPeriod_r()

QNX SDP8.0C Library ReferenceAPIDeveloper

Get a clock period

Synopsis:

#include <sys/neutrino.h>

int ClockPeriod( clockid_t id,
                 const struct _clockperiod * new,
                 struct _clockperiod * old,
                 int reserved );

int ClockPeriod_r( clockid_t id,
                   const struct _clockperiod * new,
                   struct _clockperiod * old,
                   int reserved );

Arguments:

id
The clock ID of the clock; one of the following:
  • CLOCK_REALTIME — the clock that maintains the system time.
  • CLOCK_SOFTTIME — (a QNX OS extension) this clock is active only when the processor isn't in a power-saving mode. For example, an application using a CLOCK_SOFTTIME timer to sleep wouldn't wake up the processor when the application was due to wake up. This will allow the processor to enter a power-saving mode.

    While the processor isn't in a power-saving mode, CLOCK_SOFTTIME behaves the same as CLOCK_REALTIME.

  • CLOCK_MONOTONIC — this clock always increases at a constant rate and can't be adjusted.
new
This argument is not used. Set to NULL.
old
A pointer to a _clockperiod structure where the function can store the clock period. This structure contains at least the following members:
  • uint32_t nsec — the period of the clock, in nanoseconds.
  • int32_t fract — reserved for future fractional nanoseconds. Set this field to zero.
reserved
Set this argument to 0.

Library:

libc

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

Description:

You can use the ClockPeriod() and ClockPeriod_r() kernel calls to get the clock period of the clock. These functions are identical except in the way they indicate errors. See the Returns section for details.

Note: If you want to get the clock period, consider calling clock_getres() instead of using these kernel calls directly.

Blocking states

These calls don't block.

Returns:

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

ClockPeriod()
If an error occurs, this function returns -1 is and sets errno. Any other value returned indicates success.
ClockPeriod_r()
EOK is returned on success. This function does NOT set errno. If an error occurs, the function can return any value in the Errors section.

Errors:

EFAULT
A fault occurred when the kernel tried to access the buffers provided.
EINVAL
The clock ID is invalid.
ENOTSUP
The new argument is not NULL.

Classification:

QNX OS

Safety:
Cancellation pointNo
Signal handlerYes
ThreadYes
Page updated: