NdisInitializetimer issues

Hi,
i have used NdisInitializetimer and Ndissettimer apis in my intermediate driver.
My question here is that, in the
VOID NdisInitializeTimer(
PNDIS_TIMER Timer,
PNDIS_TIMER_FUNCTION TimerFunction,
PVOID FunctionContext
);
how can i use that 2nd parameter as my callback function, actually i want to implement one timer functionality , once the timer expires, it should call the respective callback function.

i am using NdisSetTimer Function, after the expiry of time, how the callback function will be called

Thanks,
Balaji

The second parameter to NdisInitializeTimer() is a function (address of
function) that will be called when the timer expires. It is a function you
must write and must have a specific parameter definition.

When the timer expires, the system calls this function at IRQL ==
DISPATCH_LEVEL.

Within reason and the constraints of IRQL, you can then do what you want.

This is all very clearly documented in the WDK.

Moreover, there is a perfectly good example of how to use this function in
the sample

src\network\ndis\netvmini\sys\miniport.c

I found that in 15 seconds by using a file search for NdisInitializeTimer()
on the WDK src folder.

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hcl.in
Sent: Monday, August 24, 2009 8:06 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] NdisInitializetimer issues

Hi,
i have used NdisInitializetimer and Ndissettimer apis in my intermediate
driver.
My question here is that, in the
VOID NdisInitializeTimer(
PNDIS_TIMER Timer,
PNDIS_TIMER_FUNCTION TimerFunction,
PVOID FunctionContext
);
how can i use that 2nd parameter as my callback function, actually i want
to implement one timer functionality , once the timer expires, it should
call the respective callback function.

i am using NdisSetTimer Function, after the expiry of time, how the callback
function will be called

Thanks,
Balaji


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

Hi,
Thanks.i have refered the apis in the examples available in the sample code.
Can i use the NdsisSetTimer or KeSetTimer for achieving the 1mS and less than it.

Thanks,
Balaji S

Windows timer resolution is 1ms in best case. In addition, the actual timer
callback interval accuracy is much larger than 1ms. Do not expect the timer
callback to be called regularly or precisely at the specified interval.

Thomas F. Divine

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hcl.in
Sent: Tuesday, August 25, 2009 7:52 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] NdisInitializetimer issues

Hi,
Thanks.i have refered the apis in the examples available in the sample code.
Can i use the NdsisSetTimer or KeSetTimer for achieving the 1mS and less
than it.

Thanks,
Balaji S


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

To just add (perhaps unnecessarily) to what Mr. Divine already said:

The way I like to think about Windows kernel-mode timers is that they allow you to set a callback function that’s guaranteed to be called “AFTER some time period has passed” – not WHEN the time period has passed.

You don’t get a guarantee that you’ll be called on the edge of the clock pulse, you simply know that you’ll be called some time after… sometimes significantly after, depending on a lot of factors… the time period has passed.

Thus “set a time for 500ms” merely means “call me back after 500ms has gone by”: You might be called at 500ms, 510ms, or 550ms.

Peter
OSR

My testing on many different platforms has shown me not to expect any time below 10ms for the callback to run even with the timeout set to under 10ms. On moderately busy platforms 12-15ms seems to be the norm.

Larry C

xxxxx@honeywell.com wrote:

My testing on many different platforms has shown me not to expect any time below 10ms for the callback to run even with the timeout set to under 10ms. On moderately busy platforms 12-15ms seems to be the norm.

Yes. This is the “scheduler interval”, and it varies by operating
system and version. On some systems, the scheduler interval is 10ms.
On some systems it is 16ms. The KeSetTimer interval is always going
to be rounded up to a scheduler interval. SetTimer and Sleep in user
mode have the same limitation, for the same reason.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi,
Thanks for your replies.

Hi,
KeSetTimer parameter accepts time in nano seconds and Kestallexecutiona also accepts it in nano seconds, how it will work for nano seconds.
frm your threads , i understand acheiving less than 1ms is difficult.how it will accept?
is there anyother way to achive timer in 1 and less than that? i want to implement one timer application, that should run to specified to time defined interval and then it should call exactly at the end of specified interval.

Thanks,
Balaji S

Yes, times can be in the number of 100 nanoseconds but your thread will not run until the scheduler runs it which will be around 10ms.

If you need less than 10ms or need the thread to run exactly at the end of the time interval I suggest you look into Real Time OS’s.

Larry C

xxxxx@hcl.in wrote:

Hi,
KeSetTimer parameter accepts time in nano seconds and Kestallexecutiona also accepts it in nano seconds,

100 nanosecond units, actually.

how it will work for nano seconds.

It doesn’t. That’s just the common unit of time measurement in
Windows. It does not imply that you can achieve that level of accuracy.

frm your threads , i understand acheiving less than 1ms is difficult.how it will accept?
is there anyother way to achive timer in 1 and less than that? i want to implement one timer application, that should run to specified to time defined interval and then it should call exactly at the end of specified interval.

Windows is not a real-time operating system. What you ask is simply not
possible. End of story. If you need precise time intervals, you need
to use outside hardware.

Although I hesitate to mention it, KeStallExecutionProcessor is a little
different than the others. If the interval is short enough, it will
actually sit in a tight CPU loop to implement the delay. Thus, you do
get accurate delays, but you are also using 100% of the CPU during that
delay.

And a delay is different from waiting for an interval to expire.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi,
i have used Keinitializetimer in my pass thru .c file, but whenever i install my driver , it is getting crashed. i don knw whats the reason.
i have called the timer fiunctions in Driverentry function of Passthru.c sample file.

Evne i have used the NdisGetSystemuptime() in the ddriverentry function, system got crashed once again

Thanks
Balaji

My first suggestion if for you to look at WDK sample drivers to fins an
example that uses a timer.

Second, are the parameters being passed to the timer initialization function
in non-paged memory. If the Timer or the FunctionContext is in non-paged
memory then there will be a crash.

Of course, your timer function can’t be in paged memory either.

If you don’t know the difference between paged and non-paged memory, then
you must study quite a bit!

Finally, get WinDbg and learn how to use it.

Good luck!

Thomas F. Divine

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hcl.in
Sent: Monday, August 31, 2009 10:49 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] NdisInitializetimer issues

Hi,
i have used Keinitializetimer in my pass thru .c file, but whenever i
install my driver , it is getting crashed. i don knw whats the reason.
i have called the timer fiunctions in Driverentry function of Passthru.c
sample file.

Evne i have used the NdisGetSystemuptime() in the ddriverentry function,
system got crashed once again

Thanks
Balaji


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

Hi,
Thanks i have referred the examples in the kernel level sample files in wdk.

but i use only NdisGetSystemuptime() to get the system time. sysytem crashes once again.

Thanks,

Balaji S

Post your code.

Should be something like this:

ULONG UpTime;

NdisGetSystemUpTime( &UpTime );

Learn to use WinDbg…

Thomas F. Divine

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hcl.in
Sent: Monday, August 31, 2009 11:08 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] NdisInitializetimer issues

Hi,
Thanks i have referred the examples in the kernel level sample files in wdk.

but i use only NdisGetSystemuptime() to get the system time. sysytem
crashes once again.

Thanks,

Balaji S


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