Messages in this thread | | | Date | Tue, 11 Jan 2005 09:31:10 -0500 (EST) | From | linux-os <> | Subject | New Linux System time proposal |
| |
I think that Linux time should be re-thought and done over once and for all. I think that time should be the sum of three variables:
unsigned boot_time Read from RTC upon boot and never changed. signed delta_time Starts at 0, is adjusted as required. unsigned jiffies Starts at 0 upon boot, bumped by tick only.
Any time there is a requirement to obtain the system time, these three values are summed. At the time that occurs, the current value of jiffies is read and compared against a previously-saved value. The new value is saved in the old value after. If the new jiffies is less than the old, delta_time is adjusted accordingly.
What this means is that jiffies can remain a 32-bit variable and one only needs to read the system time once in awhile (before it wraps twice) to keep everything synchronized.
It also means that hardware time-outs don't get disrupted when the system clock gets set because jiffies is never touched except by the timer-tick interrupt.
Also, time doesn't get destroyed in the process of reading it. A simple user-mode daemon can periodically check certain hardware timers (like the RTC), and adjust delta_time accordingly (and slowly, like a PLL). A hook can be provided so that the delta_time variable can be tweaked by a user-mode code that synchronizes to time-servers as well. As a side-effect, this daemon does the "before jiffies wraps" read to keep everything in sync.
The actual size of the variables boot_time and delta_time can be determined by the implementor with due consideration for the resolution required.
Cheers, Dick Johnson Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips). Notice : All mail here is now cached for review by Dictator Bush. 98.36% of all statistics are fiction. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |