Re: need a timer which can be precise at 1 ms level
Braem Bart <[email protected]> Tue, 21 Aug 2012 12:30:19 +0000
| Newsgroups | gmane.network.routing.click |
|---|---|
| Message-ID | <[email protected]> |
Hi, On 19 Aug 2012, at 17:30, Feixiong Zhang <[email protected]> wrote: > Hi, all, I'm implementing a network-delay module as a click kernel module. > What the module does is that when it gets a packets, it will delay the > packet for a certain time (at millisecond order based on the packet's > incoming address) and then release it back to host stack. So I need a timer > that can fire precisely at millisecond level. I test the click timer's > function schedule_after_msec(1), but the timer actually fires after > normally 5~7 ms. Is there any other way to get a more precise timer? I took > a look at the timer document, it says there is a function adjustment() > which seems can be used. Can someone explain how it works in more detail? > > Besides, what I found for the function timer.schedule_after_msec(1) is if > there are more frequent packets entering into the delay module, the timer > firing task will be delayed much more severely. Normally it will fire after > the incoming packets become sparse, but that is already long time later > than the time it should fire. Is this normal for click? > > I'm using patchless click on linux 2.6.35-30-generic. I will appreciate a > lot if anyone can give some hints. Thanks. > Take a look at <http://read.cs.ucla.edu/click/doxygen/class_timer.html#_details> especially: "Particularly at user level, there can be a significant delay between a Timer's nominal expiration time and the actual time it runs. Elements that desire extremely precise timings should combine a Timer with aTask. The Timer is set to go off a bit before the true expiration time (see Timer::adjustment()), after which the Task polls the CPU until the actual expiration time arrives." This is how I would achieve a larger precision too. best regards, Bart -- Bart Braem PATS research group - IBBT Dept. of Mathematics and Computer Science University of Antwerp Campus Middelheim, G3.26 Middelheimlaan 1 B-2020 Antwerpen, Belgium Phone: +32 (0)3 265.38.64 Fax: +32 (0)3 265.37.77 Web: www.pats.ua.ac.be