First, the good news: I have an SNTP server that is using a serially attached GPS as the time source. That makes it a stratum-1 time server. The timestamps that it is serving are within 1ms of time.google.com or time.nist.gov, and there is little jitter or variability.
Now the bad news: It's running on a 40Mhz 80386 based system.
The code runs on a Jr just fine, but the machine is not fast enough to get to 1 or 2 ms of timing resolution and serve requests over TCP/IP. The time offset on the Jr is around 13ms, which is a lot of time. However, the machine takes around 6ms just to respond to a ping packet so I should have realized that getting to 1 or 2 ms of timing resolution with an SNTP server was not going to be possible. (This is using a real Ethernet card too, so I can't blame my usual Xircom parallel-port attached adapter.)
My new, more realistic goal for the Jr is to serve timestamps that are within 10ms of the real thing. To do this I'm going to:
- continue to speedup the 8253 interrupt, but instead of speeding it up 64x I can get by with just 16x speedup. This will reduce the system load a little.
- Scrub out all 32 bit multiplications or divisions - they require a call to the C runtime which is probably very expensive.
- Try to convert as many of the 16 bit multiplications and divides into shift operations, or partial shift operations.
- Run some micro-benchmarks to find out where the time is being spent.