ClockCycles()
Get the number of clock cycles
Synopsis:
#include <sys/neutrino.h>
#include <inttypes.h>
uint64_t ClockCycles( void );
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The ClockCycles() function returns the current value of a free-running 64-bit cycle counter. This is implemented on each processor as a high-performance mechanism for timing short intervals. On Intel, ClockCycles() reads the Time Stamp Counter (RDTSC) and on an ARM 64-bit system, it reads the Generic Timer.
You can use the
SYSPAGE_ENTRY(qtime)->cycles_per_sec
field to get the number of ClockCycles() increments in one second.
(~(uint64_t)0) / SYSPAGE_ENTRY(qtime)->cycles_per_sec
For example, a 6 GHz system will take 97 years for ClockCycles() to roll over.
synchronizedmeans the difference in time values (i.e., deltas) measured by different processors must be small enough to be not software observable. This design means that you don't have to call
ThreadCtl( _NTO_TCTL_RUNMASK, ...) to prevent
threads from migrating to another processor between calls to ClockCycles().
- Use high resolution timers
- Have tickless operation enabled
- Run for a long period of time
Having a correct value is important to ensure proper OS behavior for time and timers.
For more information, see startup-* options
in the Utilities Reference guide.
Blocking states:
This call doesn't block.
Examples:
See SYSPAGE_ENTRY().
Classification:
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | Yes |
| Signal handler | Yes |
| Thread | Yes |
