Re: timer implementation
- From: Rene Tschaggelar <none@xxxxxxxx>
- Date: Tue, 15 Aug 2006 09:47:10 +0200
wkaras@xxxxxxxxx wrote:
I'm seeking links/suggestions about the implementation of general
purpose timers. The usage of the timers would look something like:
id = start_timer(wait_time, func_called_when_time_up);
stop_timer(id);
There would also be a function called by the system timer tick, which
would call functions passed as "func_called_when_time_up" as
appropriate. (It's assumed the calling code handles all mutual
exclusion issues that may result from the time-ùp function being
called. There would also likely be some way to pass id-specific data
to the time-up function, but I don't think that would impact the broad
outlines of the design.) I'm looking for an approach that could scale
to 100s or more timers.
So far the best approach I can think of is to keep the timers in an AVL
tree where (absolute) expiration time is the search key. The big plus
is controlled worst-case behavior. Is there an approach that has at
least O(log n) worst-case and O(1) average time for both stopping a
timer and the case where the timer runs to expiration?
This usually is done in a list where only the difference
to the next timer is stored. so when decrementing the first
timer, all timers are automatically decremented as well.
Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net
.
- References:
- timer implementation
- From: wkaras
- timer implementation
- Prev by Date: Re: 1987 Z80 C compiler '2500ad' documentation
- Next by Date: ARMexpress
- Previous by thread: Re: timer implementation
- Next by thread: Re: timer implementation
- Index(es):
Relevant Pages
|