OSRLogo
OSRLogoOSRLogoOSRLogo x Subscribe to The NT Insider
OSRLogo
x

Everything Windows Driver Development

x
x
x
GoToHomePage xLoginx
 
 

    Fri, 20 Apr 2018     116751 members

   Login
   Join


 
 
Contents
  Online Dump Analyzer
OSR Dev Blog
The NT Insider
Downloads
ListServer / Forum
Driver Jobs
  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
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.

Windows Internals and Software Driver Development
LAB

Dulles (Sterling), VA
9-13 April 2018

Writing WDF Drivers I: Core Concepts
LAB

Manchester, NH
7-11 May 2018

Kernel Debugging and Crash Analysis
LAB

Manchester, NH
21-25 May 2018

 
 
 
 
x
LetUsHelp
 

Need to develop a Windows file system solution?

We've got a kit for that.

Need Windows internals or kernel driver expertise?

Bring us your most challenging project - we can help!

System hangs/crashes?

We've got a special diagnostic team that's standing by.

Visit the OSR Corporate Web site for more information about how OSR can help!

 
bottom nav links