StuBS
|
Access to the Timestamp Counter (of the current Core) More...
Enumerations | |
enum | Instruction { RDTSC , RDTSCP , CPUID_RDTSC , RDTSCP_CPUID , CR0_RDTSC } |
Functions | |
static uint32_t | ticksByProcessorInfo (void) |
Calculate the TSC frequency, if possible. | |
static uint32_t | ticksByPIT (void) |
Measure the TSC frequency using PIT. | |
uint32_t | ticks (bool use_pit=false) |
Gather the TSC frequency in ticks per milliseconds. | |
bool | available (Instruction instruction=RDTSC) |
Check availability of TSC. | |
uint64_t | nanoseconds (uint64_t delta) |
Convert a timestamp delta value to nanoseconds. | |
void | delay (uint64_t us) |
Actively wait the provided waiting time. | |
uint64_t | read (Instruction instruction=RDTSC) |
Reads the current timestamp counter. | |
Constants | |
static uint32_t | ticks_value = 0 |
Access to the Timestamp Counter (of the current Core)
Calculate the TSC frequency, if possible.
Measure the TSC frequency using PIT.
Gather the TSC frequency in ticks per milliseconds.
use_pit | Enforces the usage of the PIT if set, otherwise the processor infos are queried, at first. |
bool TSC::available | ( | Instruction | instruction = RDTSC | ) |
Check availability of TSC.
instruction | Test for the (unserialized) RDTSC or pseudo serializing RDTSCP instruction |
Convert a timestamp delta value to nanoseconds.
TSC::ticks()
prior calling this function the first time, since it uses the cached TSC frequency value gathered by ticks()
for the calculation.delta | Delta between two timestamps |
Actively wait the provided waiting time.
TSC::ticks()
prior calling this function the first time, since it uses the cached TSC frequency value gathered by ticks()
for the calculation.us | waiting time in microseconds |
|
inline |
Reads the current timestamp counter.
While reading the timestamp counter is quite easy, it is difficult to prevent out-of-order execution.
instruction | Instruction(s) used to read timestamp counter |
|
static |