[Olsr-dev] olsrd timer refactoring
Hannes Gredler
(spam-protected)
Fri Feb 29 11:11:23 CET 2008
hi erik,
tx for the FB ... i'll fixup the outstanding issues, run some more tests
and will put it into the repo in about a week or so.
/hannes
On Thu, Feb 28, 2008 at 08:51:54PM +0100, Erik Tromp wrote:
| Hi Hannes,
|
| I just did a quick test of your timer refactoring code. Good work!
| The code looks very clean which is often a good indication.
|
| Just a few small issues.
|
| As so often, some build problems :-(
|
| (spam-protected):/home/erik/Repositories/gredler.at/olsrd# make build_all
| [...]
| src/link_set.c: In function `get_best_link_to_neighbor':
| src/link_set.h:125: warning: inlining failed in call to `list2link'
| src/link_set.c:237: warning: called from here
|
| and more of this stuff. That's not that bad, but the following is
| a bit more nasty:
|
| [...]
| gcc -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wsign-compare -Waggregate-return -Wmissing-noreturn
| -Wmissing-format-attribute -Wno-multichar -Wno-deprecated-declarations -Wendif-labels -Wwrite-strings -Wbad-function-cast
| -Wpointer-arith -Wcast-qual -Wnested-externs -Winline -Wdisabled-optimization -finline-limit=50 -O2 -fPIC -g -Isrc -I../../src
| -pthread -DOLSR_PLUGIN -DUSE_FPM -Dlinux -DDEBUG -DNODEBUG -c -o src/olsrd_copy.o src/olsrd_copy.c
| src/olsrd_copy.c: In function `olsr_timed_out':
| src/olsrd_copy.c:61: error: `now' undeclared (first use in this function)
| src/olsrd_copy.c:61: error: (Each undeclared identifier is reported only once
| src/olsrd_copy.c:61: error: for each function it appears in.)
| src/olsrd_copy.c: In function `olsr_get_timestamp':
| src/olsrd_copy.c:103: error: `now' undeclared (first use in this function)
| make[2]: *** [src/olsrd_copy.o] Error 1
| make[2]: Leaving directory `/home/erik/Repositories/gredler.at/olsrd/lib/nameservice'
| make[1]: *** [nameservice] Error 2
| make[1]: Leaving directory `/home/erik/Repositories/gredler.at/olsrd/lib'
| make: *** [libs] Error 2
|
| just 'make' works fine (albeit with warnings).
|
| If the following line is changed in Makefile.inc :
|
| NO_DEBUG_MESSAGES ?= 0
|
| then...
|
| gcc -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wsign-compare -Waggregate-return -Wmissing-noreturn
| -Wmissing-format-attribute -Wno-multichar -Wno-deprecated-declarations -Wendif-labels -Wwrite-strings -Wbad-function-cast
| -Wpointer-arith -Wcast-qual -Wnested-externs -Winline -Wdisabled-optimization -finline-limit=50 -O2 -g -Isrc -pthread -DUSE_FPM
| -Dlinux -DDEBUG -c -o src/link_set.o src/link_set.c
| [...]
| src/link_set.c: In function `olsr_print_link_set':
| src/link_set.c:905: error: `nowtm' undeclared (first use in this function)
| src/link_set.c:905: error: (Each undeclared identifier is reported only once
| src/link_set.c:905: error: for each function it appears in.)
| src/link_set.c:905: error: `now' undeclared (first use in this function)
| src/link_set.c:912: error: `link_set' undeclared (first use in this function)
| src/link_set.c:912: error: structure has no member named `next'
| make: *** [src/link_set.o] Error 1
|
|
| Other than that it seems to work pretty well, at least
| on my very limited test setup.
|
| Erik
|
|
| > -----Oorspronkelijk bericht-----
| > Van: (spam-protected)
| > [mailto:(spam-protected)] Namens Hannes Gredler
| > Verzonden: dinsdag 19 februari 2008 23:56
| > Aan: olsr-dev
| > Onderwerp: [Olsr-dev] olsrd timer refactoring
| >
| > hi,
| >
| > please find attached a pointer to a change set / tree for
| > refactoring the handling of timers.
| >
| > change set http://gredler.at/hg/olsrd/rev/96526c477d56
| > tree http://gredler.at/hg/olsrd/
| >
| > as you can see the changes have been quite intrusive and i
| > had to change sometimes data structures (particularly single
| > linked lists to double linked lists).
| >
| > i'd be grateful for comments and test results / bug reports.
| >
| > tx,
| >
| > /hannes
| >
| > ---
| >
| > log:
| >
| > -slash all timeout functions and the corresponding
| > infrastructure -slash all event functions and the
| > corresponding infrastructure
| >
| > that means all polling based timer comparisons have been removed.
| > the scheduler rate can be now brought down to 10ms without
| > much additional overhead.
| >
| > -introduce a new wheel based timer similar to the BSD kernel
| > implementation described in http://www.olsr.org/docs/wucs-95-23.pdf
| >
| > there are three major calls
| >
| > olsr_start_timer()
| > olsr_stop_timer()
| > olsr_change_timer()
| >
| > alternatively there is a one-stop shop that figures out on
| > its own what to do.
| >
| > olsr_set_timer()
| >
| > this comes handy for avoiding a lot of copy and paste code
| > updating all the client code.
| >
| > the new timer API supports periodical and single shot timers.
| > once the timer expires a provided function along with a
| > context pointer is called back. After the single shot timer
| > fires the used memeory for the timer is not freed but rather
| > returned to a free memory pool for avoiding malloc() churn.
| >
| > the implementation is very efficient as all timer
| > start/stop/change operations are done in O(1) complexity.
| > walking the timer slot in the main scheduler loop has a
| > complexity of O(N/K) where K is 256 which should give
| > reasonable defaults for thousands of timers in the system.
| >
| > as a side effect all wall clock timer references have been
| > removed. now only one non- wall clock timer obtained by the
| > times() call is maintained.
| >
| > note that the olsr_secure plugin does keep its wall clock based timer.
| > it is left to the olsrd_secure plugin authors to convert this
| > to a non wall clock based timers to avoid disaster events
| > like when the system clock changes.
More information about the Olsr-dev
mailing list