Clock and timer services
Clock services are used to maintain the time of day, which is in turn used by the kernel timer calls to implement interval timers.
The ClockTime()
kernel call allows you to get or set the value of the system clock specified by an ID,
including CLOCK_REALTIME and CLOCK_MONOTONIC, which maintain the system time.
The system time is based on
ClockCycles(),
which returns the current value of a free-running 64-bit cycle counter,
operating at the frequency read from
the SYSPAGE_ENTRY(qtime)->cycles_per_sec
field.
For more information about this field
and the other time-related fields in the system page data structure,
go to the qtime reference in the System Page
chapter
in the Building Embedded Systems guide.
The ClockCycles() function is implemented on each processor architecture as a high-performance mechanism for timing short intervals. On x86 systems, ClockCycles() reads the Time Stamp Counter (RDTSC); on ARM systems, it reads the Generic Timer (CNTVCT_EL0 register).
The ClockId()
function returns a special clock ID that you can use to track the CPU time that a process or thread uses.
For more information, see
Monitoring execution times
in the Understanding the Microkernel's Concept of Time
chapter of the
QNX OS Programmer's Guide.
Microkernel call | POSIX call | Description |
---|---|---|
ClockTime() | clock_gettime(), clock_settime() | Get or set the time of day (using a 64-bit value in nanoseconds ranging from 1970 to 2554) |
ClockCycles() | N/A | Read a 64-bit free-running high-precision counter |
ClockId() | clock_getcpuclockid(), pthread_getcpuclockid() | Get a clock ID for a process or thread CPU-time clock |