[Click] Click Timers
Eddie Kohler
kohler at cs.ucla.edu
Mon Jun 15 12:03:30 EDT 2009
Hi Ashish,
An overdue explanation follows.
Ashish Sharma wrote:
> Hi,
>
> I am curious to know how timers are implemented in Click. I was wondering
> if Click timers are implemented using regular kernel timers and if that was
> the
> case if there was any implementation using hrtimers. However looking through
> the
> Click source code I found none. Instead I found that in lib/master.cc Click
> maintains its own heap for timers and runs Master::run_timers in
> routerthread.cc
That is correct. Click implements its own heap for timers, and maintains
exactly one global Linux timer for the entire router. This Linux timer, if
set, is set to a bit before the Click timer whose expiration time is nearest.
> Every time click thread gets scheduled in the kernel, all the timers in the
> heap
> are checked
Note that the heap data structure makes this check O(1).
> and the timers are woken up after they expire. Now this is
> dependent
> on how frequently Click gets scheduled, which should work better if it is
> installed
> as a kernel module.
>
> Can someone please advise, how does this approach compare to using
> hrtimers or regular kernel timers? I am trying to implement a traffic shaper
> that sends out packets on the network with very high time precision.
Click's timer heap has the advantage, in the Click context, of using the same
implementation at user level and in the kernel. The heap data structure
scales well (O(log N)) to very large numbers of timers. I'm not sure how well
hrtimers are supported in current kernels. My guess is that the Click
approach would perform roughly the same as a system that mapped Click timers
to regular kernel timers one-to-one.
Eddie
> Thanks
> Ashish
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
More information about the click
mailing list