[Previous] [Contents] [Next]

ClockPeriod(), ClockPeriod_r()

Get or set 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 );

Library:

libc

Description:

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

These kernel calls allow you to get or set the clock period of the clock.


Note: Superuser privileges are required to set the clock period.

The arguments are as follows:

id
The clock period of the clock. The clock ID, CLOCK_REALTIME, maintains the system time.
new
Contains the period to set the system clock to, if new isn't NULL. It contains at least the following members:
Member Meaning
int nsec The period of the clock in nanoseconds.
int fract Reserved for future fractional nanoseconds. Set to zero.
old
Returns the current period (before being changed by a non-NULL new), if old it isn't NULL.
reserved
Value must be 0.

All the timer_*() calls operate with an accuracy no better than the clock period. Every moment within the Neutrino microkernel is referred to as a tick. A tick's initial length is determined by the clock rate of your processor:

CPU clock speed: Default value:
>= 40MHz 1 millisecond
< 40MHz 10 milliseconds

Since a very small ticksize imposes an interrupt load on the system, and can consume all available processor cycles, the kernel call limits how small a period can be specified. The lowest clock period that can currently be set on any machine is 500 microseconds.

If an attempt is made to set a value which the kernel believes to be unsafe, the call fails with an EINVAL. The timeslice rate (for "round-robin" and "other" scheduling policies) is always four times the clock period (this isn't changeable).

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, -1 is returned and errno is set. Any other value returned indicates success.
ClockPeriod_r()
EOK is returned on success. This function does NOT set errno. If an error occurs, any value in the Errors section may be returned.

Errors:

EFAULT
A fault occurred when the kernel tried to access the buffers provided.
EINVAL
Invalid clock ID. A period was set which wasn't in a range considered safe.
EPERM
The process tried to change the period of the clock without having superuser capabilities.

Classification:

QNX 6

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

See also:

ClockAdjust()


[Previous] [Contents] [Next]