| ![[Previous]](../prev.gif) | ![[Contents]](../contents.gif) | ![[Index]](../keyword_index.gif) | ![[Next]](../next.gif) | 
Get or set a clock period
#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 );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
You can use the ClockPeriod() and ClockPeriod_r() kernel calls to get or set the clock period of the clock.
|  | If you want to get the clock period, consider calling clock_getres() instead of using these kernel calls directly. | 
These functions are identical except in the way they indicate errors. See the Returns section for details.
|  | 
 | 
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 tick size 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 10 microseconds.
If an attempt is made to set a value that 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).
These calls don't block.
The only difference between these functions is the way they indicate errors:
| Safety: | |
|---|---|
| Cancellation point | No | 
| Interrupt handler | No | 
| Signal handler | Yes | 
| Thread | Yes | 
Clocks, Timers, and Getting a Kick Every So Often chapter of Getting Started with QNX Neutrino
| ![[Previous]](../prev.gif) | ![[Contents]](../contents.gif) | ![[Index]](../keyword_index.gif) | ![[Next]](../next.gif) |