Re: No 100 HZ timer !

Jamie Lokier
2001-04-10T17:15:58Z

Mikulas Patocka wrote:
> Timers more precise than 100HZ aren't probably needed - as MIN_RTO is 0.2s
> and MIN_DELACK is 0.04s, TCP would hardly benefit from them.

Indeed, using precise timers for TCP would probably degrade performance
-- you should process a group of timer events together, when resolution
is not that important.

There are plenty of apps that need higher resolution. Software modem
comes to mind (guess why ;), though the device driver supplies the high
resolution timed interrupts in that case.

Games would like to be able to page flip at vertical refresh time --
<1ms accuracy please. Network traffic shaping benefits from better than
1ms timing. Video players want to display their frames preferably
without 10ms jitter.

Even that old classic game "snake" benefits from decent timing. I
worked on an X multiplayer snake implementation which was very
unpleasant and jerky at first. 1. Disable nagle for X connection :-)
Better but still jerky. 2. Write delay loop like this:

calculate next_event_time
select (0, 0, 0, next_event_time - 20ms)
while (gettimeofday() < next_event_time)
/* Busy loop for last 20ms. */

It's no coincidence that I've had to write another very similar event
loop recently. You can see, this sort of thing is a real waste of CPU.

-- Jamie