0

I'm writing an OS from scratch to run under qemu and I set up HPET timer. To tick every 1 millisecond, I set up:

frequency = 10^15 / counter_clock_period;
ticks = frequency / 1000;

Ticks are every 1 millisecond. frequency is 100000000 (printed to the console).

I now want to tick every 1 nanosecond. If the frequency is frequency = 100000000 I thought they were 10 ns and I could divide by 10 to get 1ns, however this does not work and time goes very slow. I tried to divide by 1000000 but it still does not count time fine. How to I get the correct ticks value given frequency so that ticks are every 1 nanosecond?

  • Umm..you cannot do much in a ns. You probably cannot do a interrupt-acknowledge cycle in one ns:( – Martin James Aug 14 '21 at 18:28
  • @MartinJames what's the min I can get, 10 - 100ns? How do I get to those? I can't find the correct way to set up in the order of ns – jakowan4 Aug 16 '21 at 08:28

0 Answers0