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
  • 8,000
  • 8
  • 46
  • 75

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
  • 22,357
  • 35
  • 46
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,836
  • 3
  • 63
  • 101
  • 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