3 ms·
The Linux version does the same, actually. As explained in the article, the Windows version is so small because it can only provide a resolution limited to the
by bonzini 9y ago
The Linux version does the same, actually.
As explained in the article, the Windows version is so small because it can only provide a resolution limited to the timer tick's resolution (2048 Hz in this case, but unless a program explicitly requests a high resolution it can be as low as 64 Hz IIRC). The cost to having a higher resolution is also a higher number of interrupts per second, which wastes power unnecessarily when you are idle[1].
Instead, as the atthe Linux version can provide a resolution limited only by the actual clocksource, which is nanoseconds in the case of the TSC. There is no background process that "updates the fields of this structure at regular intervals"; the updates only need to happen if the speed of the clock changes, for example due to an NTP update. While in the blog post it's measured to happen every millisecond, it can be configured to be lower without affecting the resolution of gettimeofday. There is also a special mode where you make it tick as slowly as 1 Hz on CPUs that have only one runnable process (if you have more than one runnable process, the scheduler needs to do context switches so the kernel cannot tick slowly).
[1] https://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ https://randomascii.wordpress.com/2013/07/08/windows-timer-r...
- jevinskie 9y agoXNU has an equivalent to vDSO: the commpage. It is also used for time.