[Olsr-dev] olsrd timer refactoring
Hannes Gredler
(spam-protected)
Tue Feb 19 23:55:58 CET 2008
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