OSRLogo
OSRLogoOSRLogoOSRLogo x Seminar Ad
OSRLogo
x

Everything Windows Driver Development

x
x
x
GoToHomePage xLoginx
 
 

    Tue, 23 Oct 2018     118021 members

   Login
   Join


 
 
Contents
  Online Dump Analyzer
OSR Dev Blog
The NT Insider
Downloads
ListServer / Forum
  Express Links
  · The NT Insider Digital Edition - May-June 2016 Now Available!
  · Windows 8.1 Update: VS Express Now Supported
  · HCK Client install on Windows N versions
  · There's a WDFSTRING?
  · When CAN You Call WdfIoQueueP...ously

Simplifying Time Interval Specification

Personally, it's never bothered me.  But if you're mathematically challenged (like my boy Peter who has a chart in his office with "milli, micro, nano" written on it and a corresponding string of zeros for each) I can see how having to specify timeout values in NT's standard "100ns intervals" could drive you nuts.

Rob Green, a member of the NTDEV list, provides the following set of macros that'll keep you from having to scratch your head and count zeros ever again.  Using these defintions, all you'll have to do is write:

interval.QuadPart = RELATIVE(SECONDS(5));

And you'll be all set.  Thanks to Rob for his suggestion, and for his permission to share it with you here.

#define ABSOLUTE(wait) (wait)

#define RELATIVE(wait) (-(wait))

#define NANOSECONDS(nanos) \
(((signed __int64)(nanos)) / 100L)

#define MICROSECONDS(micros) \
(((signed __int64)(micros)) * NANOSECONDS(1000L))

#define MILLISECONDS(milli) \
(((signed __int64)(milli)) * MICROSECONDS(1000L))

#define SECONDS(seconds) \
(((signed __int64)(seconds)) * MILLISECONDS(1000L))

 

Related Articles
Getting Started Writing Windows Drivers
A New Interface for Driver Writing -- The Windows Driver Framework

User Comments
Rate this article and give us feedback. Do you find anything missing? Share your opinion with the community!
Post Your Comment

"Simplifying Time Interval Specification"
I'm so going to include this on my kernel driver definition file :P Thanks for the info!

Rating:
19-Oct-11, Erkki Kekkonen


"Simplifying Time Interval Specification"
Timeout handling simplified. Pretty useful !!!

Rating:
16-Sep-04, Abhijit Kulkarni


Post Your Comments.
Print this article.
Email this article.
bottom nav links