reading the system clock value?
Asked Answered
W

1

1

Is there a virtual/system clock running independently when a computer is booted?

How can we read that value?

Whether answered 15/7, 2010 at 7:35 Comment(0)
L
4

Use the RDTSC x86 instruction, it reads the clocks since the system-start.

Edit: On x86-64 targets the use of inline assembly is not possible anymore, use either intrinics or a external linked object file which was generated by an assembler. Do not forget to flush the processor pipeline before using this instruction.

Linguistic answered 15/7, 2010 at 7:42 Comment(5)
can i use that for my intel x86 board..?/Whether
x86 is no board, its the instructionset of the cpu. And yes, its an x86 instruction.Linguistic
+1 I use the processor time counter very frequently to benchmark code. It's much more precise than the system time functions.Pennsylvanian
@Quonox: rdtsc is not just "an x86 instruction" it first appeared with either the Pentium or the Pentium MMX processor, I can't remember which (Wikipedia knows). It did not exist for anything before that, including the 32-bit processors 80386 and 80486.Denitadenitrate
oh this is so old but, it is still an instruction, doesn't matter when it was added. x86 is just the cpu family as far as I know.Linguistic

© 2022 - 2024 — McMap. All rights reserved.