i need a high resolution timer that expired within 100us(microsecond) that can works in windows kernel.
i tried ExSetTimerResolution to set system clock interrupt frequency to 50 like this:
ExSetTimerResolution(50, 1)
but is returned 5000 which means the smallest resolution the system can support on my platform.
Microsoft has a detailed doc here
my testing environment:
OS: windows 10 1909(testing mode with Driver Signature Verify disabled)
VM: VMware® Workstation 16 Pro
CPU: Intel(R) Core(TM) i3-9100F CPU @ 3.60GHz 3.60 GHz
MEM: 2GB
is there any way to do this?
Then you need a high resolution timer device. Quite obviously windows is not going to get you there using the os timers.
Nope. If you have a piece of hardware, you can add a timer interrupt to the hardware. Otherwise, the 500us reported by the API is it.
To do what you want, the system would need to have 10,000 timer interrupts per second. The overhead would be killer.
Note also that even with a dedicated device that fires interrupts at your desired frequency, you need to be prepared to handle delayed and coalesced interrupts.
Under normal circumstances, interrupts are handled very quickly. But your code needs to handle the situation when your interrupt isn't. And when the hardware groups two or more together before the signal gets to the CPU. At least don't crash
Just to step back, do you actually need a periodic timer event? If it's a one-time or occasional need (such as for device initialization), KeStallExecutionProcessor may be what you're looking for. Of course, it would be an awful solution if you needed to use it frequently.