0

Related to earlier question: making mistake in inline assembler in gcc

in the RDTSC or similar instruction, is the count only for your process, or is it a global count? If there is a context switch, is the only inaccuracy the cost of the context switch itself, or is the entire time the CPU is on a different job counted?

Community
  • 1
  • 1
Dov
  • 7,218
  • 7
  • 42
  • 64

2 Answers2

2

The count is for the whole system (including your running process and every other process). The instruction counts the number of ticks occurred from reset.

gusbro
  • 21,302
  • 34
  • 45
1

It counts instructions per core(hence why you shouldn't use it for timing on a multicore system). The intel developer guides should be your first stop when a query arises.

Necrolis
  • 25,222
  • 3
  • 61
  • 100
  • Actually on newer CPUs it is synchronized. There's a CPUID bit that tells you (you can find the details in the Linux implementation of the VDSO for gettimeofday). – Ben Jackson Dec 17 '10 at 18:45
  • True, however, if the cpu doesn't, your sol, which is why you should stick with higher level api's, like microsofts performance counter – Necrolis Dec 17 '10 at 18:53