klange / toaruos

A completely-from-scratch hobby operating system: bootloader, kernel, drivers, C library, and userspace including a composited graphical UI, dynamic linker, syntax-highlighting text editor, network stack, etc.
https://toaruos.org/
University of Illinois/NCSA Open Source License
6.03k stars 475 forks source link

Can we fix the clock in bochs? #256

Open klange opened 1 year ago

klange commented 1 year ago

On x86-64, Misaka uses use of the TSC as the sole clock source. Bochs, no matter how it's configured, does not provide the consistent TSC we need for this to make sense - the TSC remains tied to actual instruction cycles, so the passage of time can vary wildly depending on workload. Further, the initial timing of the TSC to wall clock is nearly random.

Linux, however, supports multiple clock sources, so if one is determined to be inaccurate or unusable, things can fall back to another. We could take a similar approach and provide alternative clock sources that are more likely to provide consistent timing information under Bochs, while still keeping the TSC for more normal circumstances.

lovemeforareason commented 1 year ago

Bochs has support for the CMOS RTC and PIT clocks. Is it possible to maybe harness those?