Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 4  
12 Feb 18 02:54
Manikanta mylavarapu
xxxxxx@industeqsite.com
Join Date: 12 Feb 2018
Posts To This List: 1
milli/micro/nano seconds to cpu ticks conversion

Hi to all. --->I am porting one driver from linux to windows.we are using KMDF.Like "msecs_to_jiffies" in linux, in windows how can i convert milli seconds to cpu clock ticks. --->I googled and i found "KeQueryPerformanceCounter" instruction. --->What is Performence counter? --->How can i use this instruction to meet my requirement? Please give me a solution.
  Message 2 of 4  
12 Feb 18 13:36
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11922
milli/micro/nano seconds to cpu ticks conversion

xxxxx@industeqsite.com wrote: > --->I am porting one driver from linux to windows.we are using KMDF.Like "msecs_to_jiffies" in linux, in windows how can i convert milli seconds to cpu clock ticks. > --->I googled and i found "KeQueryPerformanceCounter" instruction. > --->What is Performence counter? > --->How can i use this instruction to meet my requirement? That's not a requirement, that's an implementation detail.  Why do you need the time in "jiffies"?  What is the actual requirement?  In almost every case, you want to go the other direction -- you have a CPU-specific time period, and you want the value in microseconds or milliseconds.  Hardware devices NEVER work in "jiffies". You should also understand that the Linux "jiffy" is not "CPU ticks".  It is the time between timer interrupts, typically a value between 1ms and 10ms.  Windows has a similar range, from 1ms to 16ms. The exact source of KeQueryPerformanceCounter depends on the hardware and the operating system version.  In olden days, it was based on the motherboard countdown timer, which was also used to generate the timer interrupt.  Later, it came from the High-Precision Event Timer (HPET).  These days, it is commonly derived from the CPU cycle counters.  KeQueryPerformanceCounter also returns to you the frequency of the counter, so you can derive meaningful time from the value. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 3 of 4  
14 Feb 18 20:11
Pavel A
xxxxxx@fastmail.fm
Join Date: 21 Jul 2008
Posts To This List: 2418
milli/micro/nano seconds to cpu ticks conversion

> in windows how can i convert milli seconds to cpu clock ticks. Converting is easy. The time unit in Windows is always 100 nano seconds so 1 ms is 10000 in these units. This can be used to specify delays, like in KeSetTimer, KeWaitForSingleObject, KeDelayExecutionThread etc. Remember only to use *negative* values for relative time! Usually you don't need to express time in ticks. But if you want to, you can get the tick value with ExQueryTimerResolution. > I googled and i found "KeQueryPerformanceCounter" instruction. KeQueryPerformanceCounter - as its documentation says - is used to "acquire high resolution ... time stamps for time interval measurements". If this is what you need, use it. Good luck. -- pa
  Message 4 of 4  
14 Feb 18 20:22
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11922
milli/micro/nano seconds to cpu ticks conversion

xxxxx@fastmail.fm wrote: >> in windows how can i convert milli seconds to cpu clock ticks. > Converting is easy. The time unit in Windows is always 100 nano seconds so 1 ms is 10000 in these units. EXCEPT, of course, for KeQueryPerformanceCounter, which is the direction our poster is going. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 15:28.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license