Hey all;
Noob here, working with a SDK of a experimental piece of hardware based on a 5.x implementation of a NDIS Miniport. I’m currently expanding it with information involving custom made RTS/CTS’s; part of this programming IDEALLY would involve INTENTIONALLY delaying any involvement by various components by using timers that purposely lock the driver from doing anything until they expire (for example, this would REALLY help with syncronizing RTS’s and CTS’s --if a destination receives two RTS’s within too short of a “time” it would be able to discard one.)
Do you have any tips with regards to which Windows API’s to call in order to involve timing? I’ve toyed around with KeQuerySystemTime and it always returned the same number, which was useless.
Current implementation is using rdtsc() which I’m aware is kind of a terrible idea, especially on multi-processor machines, though I don’t know if the same logic applies to multi-core machines (all machines on the project are Intel i7 870’s). rdtsc() sometimes returns a negative value (I’m storing it in a ULONG, what the heck; should it be ULONG LONG?) which isn’t helping. I feel I’m getting close with this approach though; if I can get moderately accurate system times (like down to 100 ms would be nice, though I honestly don’t know what all is feasible or not; that’s why I’m turning to you guys!) then I feel I could finish my code.
Any tips and tricks would be awesome.
Thanks, all!
-Cory
Look at KeQueryPerformanceCounter that is what it is there for.
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
“xxxxx@umich.edu” wrote in message
news:xxxxx@ntdev:
> Hey all;
>
> Noob here, working with a SDK of a experimental piece of hardware based on a 5.x implementation of a NDIS Miniport. I’m currently expanding it with information involving custom made RTS/CTS’s; part of this programming IDEALLY would involve INTENTIONALLY delaying any involvement by various components by using timers that purposely lock the driver from doing anything until they expire (for example, this would REALLY help with syncronizing RTS’s and CTS’s --if a destination receives two RTS’s within too short of a “time” it would be able to discard one.)
>
> Do you have any tips with regards to which Windows API’s to call in order to involve timing? I’ve toyed around with KeQuerySystemTime and it always returned the same number, which was useless.
>
> Current implementation is using rdtsc() which I’m aware is kind of a terrible idea, especially on multi-processor machines, though I don’t know if the same logic applies to multi-core machines (all machines on the project are Intel i7 870’s). rdtsc() sometimes returns a negative value (I’m storing it in a ULONG, what the heck; should it be ULONG LONG?) which isn’t helping. I feel I’m getting close with this approach though; if I can get moderately accurate system times (like down to 100 ms would be nice, though I honestly don’t know what all is feasible or not; that’s why I’m turning to you guys!) then I feel I could finish my code.
>
> Any tips and tricks would be awesome.
>
> Thanks, all!
>
> -Cory
Have you looked at the documentation for the WDK and the examples found therein? You should be using KeQueryPerformanceCounter for benchmarking operatons. It stores it’s return value in a pointer to a LARGE_INTEGER. Which by the way is what KeQuerySystemTime does, so if the value never changes I would suggest you are looking at the POINTER to the returned LARGE_INTEGER and NOT the LARGE_INTEGER. You should be doing:
MyTime->QuadPart
to get to the 64 bit timer value.
Gary G. Little
----- Original Message -----
From: xxxxx@umich.edu
To: “Windows System Software Devs Interest List”
Sent: Monday, February 21, 2011 11:16:53 AM
Subject: [ntdev] (Moderately) Accurate System Time in Kernel Mode Driver (Miniport)?
Hey all;
Noob here, working with a SDK of a experimental piece of hardware based on a 5.x implementation of a NDIS Miniport. I’m currently expanding it with information involving custom made RTS/CTS’s; part of this programming IDEALLY would involve INTENTIONALLY delaying any involvement by various components by using timers that purposely lock the driver from doing anything until they expire (for example, this would REALLY help with syncronizing RTS’s and CTS’s --if a destination receives two RTS’s within too short of a “time” it would be able to discard one.)
Do you have any tips with regards to which Windows API’s to call in order to involve timing? I’ve toyed around with KeQuerySystemTime and it always returned the same number, which was useless.
Current implementation is using rdtsc() which I’m aware is kind of a terrible idea, especially on multi-processor machines, though I don’t know if the same logic applies to multi-core machines (all machines on the project are Intel i7 870’s). rdtsc() sometimes returns a negative value (I’m storing it in a ULONG, what the heck; should it be ULONG LONG?) which isn’t helping. I feel I’m getting close with this approach though; if I can get moderately accurate system times (like down to 100 ms would be nice, though I honestly don’t know what all is feasible or not; that’s why I’m turning to you guys!) then I feel I could finish my code.
Any tips and tricks would be awesome.
Thanks, all!
-Cory
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer