I believe you are wrong ;). Remember, DPC dequeueing is not
deterministic and the mouse DPC could be stuck behidng many other DPCs
on the machine (trust me, I have seen this happen). For instance, under
a high network load, the NICs DPC can squeeze out the mouse DPC.
Ironically, all this doesn’t make much of a performance difference in
the real world and is more of a ?>
perfectionist ambition.
It’s all about balancing pros and cons, which I am not the very best
at.
You kind of made my point for me, you are overoptimizing for a path that
does not require such optimization. There is a lot more processing that
occurs after you let the mouse packet go up to the RIT, you are probably
just noise in the overall time it takes to convert a mouse hw event into
a windows message. Instead of calling QPC for every packet, call it
once at the top of the function and use the same timestamp for each
packet. The counter is most likely not going to change while your
routine is executing, and if it does, the change is so slight it is not
worth the extra overhead.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hushmail.com
Sent: Saturday, June 23, 2007 9:50 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question abot mouse service callback routine
scenarios
Doron Holan wrote:
For instance, if the device interrupts for one packet
and before the DPC for ISR can run,
interrupts for another packet.
PS/2 mouse devices have a maximum sample rate of 200 Hz.
Thus, ISR & DPC have about 5 ms to complete until the next packet could
arrive.
Correct me if I’m wrong, but I wouldn’t call that a normal circumstance.
Doron Holan wrote:
Why do you care?
I’m currently in the final optimization stage of development.
My filter driver conditionally timestamps the incoming mouse packets and
modifies them in accordance to these timestamps.
I know it’s bad, but I need KeQueryPerformanceCounter for millisecond
granularity (the only alternative, ExSetTimerResolution, is even more
evil
).
The naive approach is to walk through the MOUSE_INPUT_DATA array,
calling QPC and doing related computations with every iteration again
and again.
This is obviously not the most efficient solution for more than one
packet, but otherwise I’d have to do heavy branching to avoid
superfluous calculations, thus impairing the source code’s readability
and exposing myself to possible branch mispredictions.
In other words, I try to keep the execution flow as linear and simple as
possible.
Now, I have been thinking: What if multiple packets can only occur under
heavy system load anyways?
After all, it’s just a mouse I’m dealing with and in case of an
overloaded system, inconsistent mouse feeling would be one of the user’s
least worries.
Following that assumption, I’d only process the last packet (leaving the
possible other ones untouched) and have a very lean, uncomplicated code,
which would furthermore happen to be the most efficient method for the
most likely scenario of only one packet at a time.
Therefore, I was also asking for the packet order and the guarantee of
at least one mouse packet in the service callback routine (InputDataEnd
- 1 could otherwise point to invalid memory).
Ironically, all this doesn’t make much of a performance difference in
the real world and is more of a perfectionist ambition.
It’s all about balancing pros and cons, which I am not the very best at.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer