-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!
I've implemented a simple repeating timer for OpenPBX so we can
replace the zaptel timing in some parts. I have also used the timer to
replace zaptel for IAX trunking, and in my limited testing it works
fine. The code is available in a branch with url:
        svn://svn.openpbx.org/openpbx/branches/egnarf/timers

On a standard linux 2.6.14 kernel with kernel-preemption enabled and
HZ set at 1000 I get better than 1ms precision (usually around 0.5ms)
when the system is lightly loaded.

With the HRT-patches and a 2.6.15 kernel I measured a resolution
better than 20ns on a very loaded system (did make -j32 in the kernel
source). The HRT-patches are available at
        http://www.tglx.de/projects/hrtimers/

I've attached a trivial patch that starts a 10 sec timer that prints
the local time in the console. This is a very simple test of the
timers. Run this test on a loaded system to see what precision you get.


With these timers in place and working we should look at other things
that might be timerized.
I've looked at the scheduler (corelib/sched.c) and it seems to need a
manual push to actually do anything. From what I can see you need to
call opbx_sched_runq for it to run the tasks.
This should be handled by a timer.
Unfortunately I'm afraid that if I try it stuff will break. So does
anybody know much about the scheduler and if / how it would be safe to
timerize it?

Ps. Please test and comment on the timers. But you will probably need
a very recent kernel to get good precision.

/B
- -- * GPG-Key: http://evil.gnarf.org/mrbk.pgp

A: Because we read from top to bottom, left to right.
Q: Why should i start my reply below the quoted text?
- -- http://www.i-hate-computers.demon.co.uk/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFD8j/wckvkFeO3ANARAutNAJ9pUDC4Yk+VocyUJdj3KR5yyVTR9wCg3Nf0
H41IYYYPlkCaHRrVxdIXRQo=
=DHzi
-----END PGP SIGNATURE-----
Index: corelib/openpbx.c
===================================================================
--- corelib/openpbx.c   (revision 1378)
+++ corelib/openpbx.c   (working copy)
@@ -121,6 +121,19 @@
 #define OPBX_MAX_CONNECTS 128
 #define NUM_MSGS 64
 
+
+#include <openpbx/timer.h>
+
+void testfunc(opbx_timer_t *t, void *d)
+{
+       struct timeval tv;
+
+       gettimeofday(&tv, 0);
+
+       opbx_log(LOG_ERROR, "Timer triggered at %ds %dns\n", tv.tv_sec,
+                tv.tv_usec);
+}
+
 #define WELCOME_MESSAGE opbx_verbose(PACKAGE_STRING " SVN-" SVN_VERSION " 
http://www.openpbx.org - The True Open Source PBX\n"); \
                opbx_verbose( 
"=========================================================================\n")
 
@@ -2339,6 +2352,12 @@
                snprintf(title, sizeof(title), "OpenPBX Console on '%s' (pid 
%d)", hostname, opbx_mainpid);
                set_title(title);
 
+
+               opbx_timer_t tim;
+               opbx_repeating_timer_create(&tim, 10000000, testfunc, 0);
+               opbx_timer_start(&tim);
+               
+
                for (;;) {
                        buf = (char *)el_gets(el, &num);
                        if (buf) {
_______________________________________________
Openpbx-dev mailing list
[email protected]
http://lists.openpbx.org/mailman/listinfo/openpbx-dev

Reply via email to