Aufgabe 6: Synchronisation
TSC Namespace Reference
Access to the Timestamp Counter (of the current Core) More...
Enumerations | |
enum | Instruction { RDTSC , RDTSCP , CPUID_RDTSC , RDTSCP_CPUID , CR0_RDTSC } |
Functions | |
uint32_t | ticks (bool use_pit=false) |
Gather the TSC frequency in ticks per milliseconds. More... | |
bool | available (Instruction instruction=RDTSC) |
Check availability of TSC. More... | |
uint64_t | nanoseconds (uint64_t delta) |
Convert a timestamp delta value to nanoseconds. More... | |
void | delay (uint64_t us) |
Actively wait the provided waiting time. More... | |
uint64_t | read (Instruction instruction=RDTSC) |
Reads the current timestamp counter. More... | |
Detailed Description
Access to the Timestamp Counter (of the current Core)
Enumeration Type Documentation
enum TSC::Instruction |
Function Documentation
uint32_t TSC::ticks | ( | bool | use_pit = false | ) |
Gather the TSC frequency in ticks per milliseconds.
- Parameters
-
use_pit Enforces the usage of the PIT if set, otherwise the processor infos are queried, at first.
- Returns
- Number of TSC ticks per milliseconds
bool TSC::available | ( | Instruction | instruction = RDTSC | ) |
Check availability of TSC.
- Parameters
-
instruction Test for the (unserialized) RDTSC or pseudo serializing RDTSCP instruction
- Returns
- true if RDTSC[P] is available
uint64_t TSC::nanoseconds | ( | uint64_t | delta | ) |
Convert a timestamp delta value to nanoseconds.
- Note
- It is necessary to execute
TSC::ticks()
prior calling this function the first time, since it uses the cached TSC frequency value gathered byticks()
for the calculation.
- Parameters
-
delta Delta between two timestamps
- Returns
- Equivalent time in nanoseconds
void TSC::delay | ( | uint64_t | us | ) |
Actively wait the provided waiting time.
- Note
- It is necessary to execute
TSC::ticks()
prior calling this function the first time, since it uses the cached TSC frequency value gathered byticks()
for the calculation.
- Parameters
-
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.
- See also
- How to Benchmark Code Execution Times on Intel® IA-32 and IA-64 Instruction Set Architectures [benchmark_code_execution.pdf]
- Parameters
-
instruction Instruction(s) used to read timestamp counter
- Returns
- Timestamp in TSC ticks