高分辨率睡眠 [英] High resolution Sleep

查看:75
本文介绍了高分辨率睡眠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sleep()函数睡眠时间为1毫秒,有一种方法可以使一个

线程睡眠时间不到一毫秒?我知道的一种方法是使用

性能计数器,它不是真正的睡眠状态(循环并再次检查并再次使用
并使用CPU时间)。

谢谢


Charles Zhang

Sleep() function Sleep at lease 1 millisecond, there is a way to make a
thread to sleep less than a millisecond? One way I know of is using
performance counter which is not really sleep ( loop and check again and
again and uses CPU time).

Thanks

Charles Zhang

推荐答案

Even Sleep()没有真正的1毫秒分辨率。


没有比Windows AFAIK中的性能计数器更好的计时器。


Mark


-

Mark Salsbery

Microsoft MVP - Visual C ++

" Charles Zhang" < Ch ********** @ newsgroups.nospamwrote in message

news:Ov ************** @ TK2MSFTNGP02.phx.gbl ...
Even Sleep() doesn''t have true 1 ms resolution.

There''s no better timer than the performance counter in Windows AFAIK.

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++
"Charles Zhang" <Ch**********@newsgroups.nospamwrote in message
news:Ov**************@TK2MSFTNGP02.phx.gbl...

Sleep()函数睡眠时间为1毫秒,有一种方法可以使一个

线程睡眠时间少于一个毫秒?我知道的一种方法是使用

性能计数器,它不是真正的睡眠状态(循环并再次检查并再次使用
并使用CPU时间)。

谢谢


Charles Zhang
Sleep() function Sleep at lease 1 millisecond, there is a way to make a
thread to sleep less than a millisecond? One way I know of is using
performance counter which is not really sleep ( loop and check again and
again and uses CPU time).

Thanks

Charles Zhang


和...时间结构怎么样?


hh:mm:ss,dd


其中99> = dd> = 0


dd是毫秒......


和思考多一点,cpu cicles怎么样?


" Mark Salsbery [MVP ]" < MarkSalsbery [MVP] @newsgroup.nospamescribióenel

mensaje新闻:75 ************************** ******** @ microsof t.com ...
and.. what about with time struct?

hh:mm:ss,dd

where 99>=dd>=0

dd are miliseconds...

and thinking a little more, what about cpu cicles?


"Mark Salsbery [MVP]" <MarkSalsbery[MVP]@newsgroup.nospamescribió en el
mensaje news:75**********************************@microsof t.com...

Even Sleep()没有真正的1 ms分辨率。


没有比Windows AFAIK中的性能计数器更好的计时器。


Mark


-

Mark Salsbery

Microsoft MVP - Visual C ++


" Charles Zhang" < Ch ********** @ newsgroups.nospamwrote in message

news:Ov ************** @ TK2MSFTNGP02.phx.gbl ...
Even Sleep() doesn''t have true 1 ms resolution.

There''s no better timer than the performance counter in Windows AFAIK.

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++
"Charles Zhang" <Ch**********@newsgroups.nospamwrote in message
news:Ov**************@TK2MSFTNGP02.phx.gbl...

> Sleep()函数睡眠时间为1毫秒,有一种方法可以使一个
线程睡眠时间不到一毫秒?我知道的一种方法是使用
性能计数器,它不是真正的睡眠状态(循环并再次检查并再次使用CPU时间)。

谢谢

Charles Zhang
>Sleep() function Sleep at lease 1 millisecond, there is a way to make a
thread to sleep less than a millisecond? One way I know of is using
performance counter which is not really sleep ( loop and check again and
again and uses CPU time).

Thanks

Charles Zhang



你可以使用clockres来自Sysinternals(今天的微软)在你的机器上看到

的最低分辨率。我的(四核是15.6毫秒)。


我认为不到15毫秒是不可能的,并且肯定15毫秒的睡眠变成了很多的b $ b更多时间因为Windows使用睡眠来完成其他任务,

如果你放一个for()循环,你的CPU时间会被scalated到100%和

肯定会没有更精确的睡眠。


" Charles Zhang" < Ch ********** @ newsgroups.nospamwrote in message

news:Ov ************** @ TK2MSFTNGP02.phx.gbl ...
You can use "clockres" from Sysinternals (today Microsoft) to see the
minimum resolution in your machine. Mine (Quad core is 15.6 ms).

I think less than 15 ms is impossible, and surely a sleep of 15 ms becomes
in a lot of more time because Windows uses that sleeping to do other tasks,
and if you put a for() loop you will get your CPU time scalated to 100% and
surely with no more precission that sleep.

"Charles Zhang" <Ch**********@newsgroups.nospamwrote in message
news:Ov**************@TK2MSFTNGP02.phx.gbl...

Sleep()函数睡眠时间为1毫秒,有一种方法可以使一个

线程睡眠时间少于一个毫秒?我知道的一种方法是使用

性能计数器,它不是真正的睡眠状态(循环并再次检查并再次使用
并使用CPU时间)。

谢谢


Charles Zhang
Sleep() function Sleep at lease 1 millisecond, there is a way to make a
thread to sleep less than a millisecond? One way I know of is using
performance counter which is not really sleep ( loop and check again and
again and uses CPU time).

Thanks

Charles Zhang



-

Microsoft Visual C ++ MVP

========================

Mi blogsobreprogramación: http://geeks.ms/blogs/rfog

Momentos Leves:< a rel =nofollowhref =http://momentosleves.blogspot.com/target =_ blank> http://momentosleves.blogspot.com/

Libros, cienciaficciónyprogramación

====================================== ==

Es un hecho que el hombre tiene que controlar la ciencia y chequear

ocasionalmente el avance delatecnología。

- Thomas Henry赫胥黎。

--
Microsoft Visual C++ MVP
========================
Mi blog sobre programación: http://geeks.ms/blogs/rfog
Momentos Leves: http://momentosleves.blogspot.com/
Libros, ciencia ficción y programación
========================================
Es un hecho que el hombre tiene que controlar la ciencia y chequear
ocasionalmente el avance de la tecnología.
-- Thomas Henry Huxley.


这篇关于高分辨率睡眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆