Re:Nanosecond timestamp collisions are common
by jsolson on Friday July 21, 2023 @10:15AM
(#36814027)
Some of this is not current.
Constant-rate TSCs are ~15-20 years old. Synchronized TSCs are at least ten.
Also RDTSC produces a 64-bit result, so it does not overflow at a rate of several Hz.
Re:Nanosecond timestamp collisions are common
by datenwolf on Friday July 21, 2023 @11:18AM
(#36814815)
It's 64 bit on 64 systems. In the world of hard realtime applications there's still a huge armada of systems out there in the field running on 32 bit (think motion control, CNC machines, industrial robotics). If you're developing software that's concerned with this kind of precision, you might find yourself confronted with such "outdated" systems more often, than not.
If you really, really, really need system wide, nanosecond precision timestamps, you'll have to resort to dedicated hardware incrementing a counter at the desired rate, and with a well known latency for each read access. On the hardware and driver level you'd have some MMIO port mapped into user space with an identity transform between bus address and process address space.
However this still doesn't solve the problem, of the scheduler being able to throw in several milliseconds between reading the high precision timer value into a register and writing it back into the memory holding the timestamp variable. Seriously, on your typical computer system software derived timestamps at more than 100µs resolution are kind of bogus.