Which system hardware timer does clock_gettime
function in linux use internally to give nano seconds level resolution back to the user code when invoked to measure elapsed time for a given segment of code ?
Modern CPUs run at several GHz clock frequency. A frequency of 1 GHz equals a clock period of 1 ns. So running a (wide) counter at 1 GHz gives a time resolution in nanoseconds. This does not mean that the time is as accurate as it is displayed. The value has just such a high resolution.