aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/arch/x86_64.md
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86_64.md')
-rw-r--r--src/arch/x86_64.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/arch/x86_64.md b/src/arch/x86_64.md
index 2635a4e..1f7ffdd 100644
--- a/src/arch/x86_64.md
+++ b/src/arch/x86_64.md
@@ -147,6 +147,25 @@ mov cx, 0x10
rep stosb
```
+## Time stamp counter - `rdtsc`
+```c
+static inline uint64_t rdtsc() {
+ uint32_t eax, edx;
+ asm volatile("rdtsc" : "=d"(edx), "=a"(eax)::);
+ return (uint64_t)edx << 32 | eax;
+}
+```
+> Constant TSC behavior ensures that the duration of each clock tick is uniform
+> and supports the use of the TSC as a wall clock timer even if the processor
+> core changes frequency. This is the architectural behavior moving forward.
+> - 18.17 TIME-STAMP COUNTER - [intel64-vol3][intel64_vol3]
+
+On linux one can check the `constant_tsc` cpu flag, to validate if the
+implemented TSC ticks with a constant frequency.
+```sh
+grep constant_tsc /proc/cpuinfo
+```
+
## [SysV x86_64 ABI][sysvabi]
### Passing arguments to functions