Synchronizing processor clocks in Linux

Synchronizing processor clocks in Linux

This is a question received by Intel Software Network Support, followed by a response received by an expert at Intel:

Q. I have looked at the Intel Software Network article by Paul Work and Khang Nguyen entitled Measure Code Sections Using The Enhanced Timer. This is a very useful article. Does Linux* have a facility for synchronizing processor clocks similar to what Windows* has? This would be very useful to Linux kernel and driver developers who want to get timing information, wouldn't it?

A. Linux is a bit different than Windows in this regard. By default, if you use the gettimeofday() API to get the current time, Linux will give you the time as accurately as possible, usually in the microsecond or finer range. This is done using the RDTSC timer, HPET timer or ACPI PM-timer hardware features depending on which is best/most accurate for your platform. (These latter 2 are I think what the article calls Etimer.)

As for the RDTSC synchronization; Linux will automatically synchronize this between processors in a multiprocessor system as part of the normal boot process. When Linux decides to use RDTSC internally to implement gettimeofday(), the effect of Intel SpeedStep Technology as described in the article is automatically compensated for by the kernel; the programmer does not need to do anything extra or otherwise worry about this.

Soin conclusion: Linux already is using the best of the timers that our platforms offer today, and exposes this via the standard gettimeofday() API to applications without any need for the application to be made aware of new hardware capabilities. This also means that when we make an even better timer available (not sure that is needed; the HPET timer we provide today is very good), only the kernel needs to learn about it but applications do not need to be changed.

==

Lexi S.

IntelSoftware NetworkSupport

http://www.intel.com/software

Contact us

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.