Re: High resolution timer on kernel mode

Tech-Archive recommends: Speed Up your PC by fixing your registry



OK. For me the situation is different. I dont necessarily need a high res
timer all of the time ... I just need my packet dequeue to keep pace with my
packet enqueue ... so I can always get rid of the packets as fast as I get
them, if I need to. So for me if the packets are coming in very slowly ...
it doesn't matter ... there may only be 5 packets per 300ms ... but thats ok
because I only need to dequeue them at 5 packets per 300ms. When packets
come in very fast ... say 5 packets per 1ms (60mbps) then I must dequeue them
at 5 packets per 1ms ... which is better than a timer will get me and I do
this off of the back of my ptReceivePacket function ... which is called by
the miniport driver ... probably in its interrupt ... which is not timer
generated but nic harware interrupt generated.

It was a few years ago that I really looked into all of the alternatives,
and from what I remember there is no way of getting a better than 10ms timer
.... you can setup your timer to go off at about 5ms and sometimes it will go
off at 7ms, sometimes 10ms ... there is no guaranty. I even tried 2
staggered 10ms timers ... started the first, then waited 5ms and started the
second ... guess what? Both timers went off at the same time ... not 5ms
apart as I hoped.

You can have a thread running that just loops and measures time (using very
high res functions) and this thread can be used to generate your timer, i.e.
do your callback, at a much finer res ... but the functions you use to
measure the time are very expensive when you call them in a loop like this
and you may well bring the system to a halt!

You can use ExSetTimerResolution to change the resolution of the system
clock interrupt but this will affect the entire system and the help tells you
to use it with caution. You would probably use this function if, and only
if, this system does nothing at all except run your driver!

Good luck.
Mirage2k2

"vs" wrote:

Mirage,

Could you elaborate a bit more on the trick you used in the IM driver.
Does it also help for the single TCP connection case. High latencies
with single TCP connection scenario like a copy send seem to suffer
most...

ExSetTimerResolution seem to be prohibited by WHQL. There seem to be no
alternatives for NDIS drivers that are not NDIS-WDM. Also since IM
drivers cannot be WDM drivers. Are there any facilities to generate
high resolution timer callbacks (not measure time) for NDIS/NDIS IM
drivers?

regards
vs

Tim Roberts wrote:
Anand Choubey <AnandChoubey@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Please suggest me kernel mode api for high resolution time.
I read that keQueryPerformanceCounter is high performance counter but it
disable interrupts.

It depends. On a uniprocessor machine, KeQueryPerformanceCounter uses the
motherboard countdown timer, which can take a couple of microseconds. I
find it extremely unlikely that having interrupts disabled for the length
of two port IN instructions will affect your application, unless you call
it a half million times a second.

On a multiprocessor machine, KeQPC uses the cycle counter, and interrupts
do not have to be disabled.
--
- Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.


.



Relevant Pages

  • [RFC] HOWTO use NAPI to reduce TX interrupts
    ... that all good ethernet drivers call their TX descriptor reclaim function ... Many devices trigger an interrupt for each ... +the skb. ... +the interrupt and the time that new user packets have arrived in the ...
    (Linux-Kernel)
  • Re: RFC: issues concerning the next NAPI interface
    ... Schedule the timer in the poll function ... The timer function could then just call netif_rx_schedule to ... Interrupt mitigation only works if it helps you avoid interrupts. ... So if you set this timer, it triggers, and no packets arrive, you are ...
    (Linux-Kernel)
  • Re: RFC: issues concerning the next NAPI interface
    ... So NAPI does not work very well here and the interrupt ... Introduce a timer, but don't start to use it to combine packets unless you ... Lets say its 10 per millisecond ("typical" for a gigabit eth runnning ...
    (Linux-Kernel)
  • Re: High resolution timer on kernel mode
    ... I have a TDI driver and its IOCTRL dispatch function gets called by ... timer all of the time ... ... So for me if the packets are coming in very slowly ... ... generated but nic harware interrupt generated. ...
    (microsoft.public.development.device.drivers)
  • Re: High resolution timer on kernel mode
    ... I need to take the packet in this IM driver and send it to a special ... how to use its interrupt to speed up my NDIS IM driver. ... timer all of the time ... ... So for me if the packets are coming in very slowly ... ...
    (microsoft.public.development.device.drivers)