[Asterisk-Dev] ztdummy accuracy improvements on kernel 2.6

Tony Mountifield tony at softins.clara.co.uk
Mon May 16 04:06:16 MST 2005


I've been using MeetMe via IAX with no problems on a FC1 box with the
2.4 kernel and zaprtc for timing.

Recently I've set up a FC3 box with the 2.6 kernel, and have been using
ztdummy for timing. Using the same IAX sources to a MeetMe conference,
I found that there was an increasing delay between a participant speaking
and the others hearing him. Over 10-20 minutes this crept up to several
seconds!

The only difference between the two boxes were the kernel and the timing,
so I looked at ztdummy. I think the use of add_timer() and the jiffy
counter doesn't give enough accuracy for MeetMe use (nor probably for IAX
trunking, although I'm not using trunking).

This got me thinking and looking again at zaprtc.

In 2.4, in order to use zaprtc it was necessary to recompile the kernel
to make the rtc a module or not included (CONFIG_RTC=m or CONFIG_RTC=n).

In the 2.6 version of drivers/char/rtc.c I found a new feature to hook
a function into the rtc interrupt, using the functions rtc_register(),
rtc_unregister() and rtc_control(). There is an example of their use
in sound/code/rtctimer.c. This would enable an rtc-based zap timer to
be implemented without any kernel changes.

So I rewrote the 2.6-specific parts of ztdummy.c to use these rtc funcs
instead of add_timer(), adopting the same technique as in zaprtc, which
is to set the rtc irq to 1024Hz (it must be a power of 2), and then
skip 3 out of every 128 irqs (evenly spaced) to give 1000 zaptel
interrupts each second.

Repeating my tests, I found that the increasing delay was no longer
present. This confirmed to me that the jiffy-based ztdummy is not accurate
enough, and than an rtc-based one would be a big improvement.

I intend to submit this to mantis, but could approach it in two ways:
1. Make it a completely new module called ztrtc, and only for 2.6.
2. Make it an update to ztdummy.c, replacing the add_timer code with
   the rtc_request() code.

Any recommendations which of the two I should do?

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-dev mailing list