相当于硬盘扫描的CPU消耗
我希望扫描磁盘结构的软件在后台工作,但降低扫描磁盘结构不起作用的线程的优先级。我的意思是,即使你的程序只消耗了 1% 的处理器时间,你仍然会感觉计算机正在努力工作,甚至死机。是否可以在Win32中实现相当于CPU消耗的“硬盘时间消耗”
I would like my software that scans disk structure to work in background but lowing the priority for the thread that that scans disk structure doesn't work. I mean you still have the feeling of the computer hard working and even freezing even if your program consumes only 1 percent of the processor time. Is it possible to implement "hard disk time consumption" equivalent of CPU consumption in Win32
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 Vista 开始,您可以降低 IO 优先级,这与 CPU 优先级是分开的。
http://msdn.microsoft.com/en-us /library/ms686219(VS.85).aspx
对于 XP、2003 及更早版本,您必须找到其他方法来限制磁盘活动,例如经常使用 Sleep()。
Since Vista you can lower your IO priority, which is separate from CPU priority.
http://msdn.microsoft.com/en-us/library/ms686219(VS.85).aspx
For XP, 2003 and older, you'd have to find some other way to throttle your disk activity, like using Sleep() often.
磁盘访问通常通过每秒几个不同的指标传输(可以分解为读/写)以及每秒读取或写入的数据来衡量。如果您想限制磁盘扫描应用程序的影响,一种方法是跟踪这些指标中的一个(或两个),确定合理的上限,并定期使线程休眠一段时间。除了以最透明、间接的方式之外,您对 CPU 调度所做的任何事情都无法有效地完成此任务。
Disk accesses are typically measured by a few different metrics transfers per second (which can be broken down into reads/writes), and data read or written per second. If you want to limit the impact of your disk scanning application, one way to do this would be to track one (or both) of these metrics, determine a reasonable cap, and periodically sleep your thread for some time period. Nothing you can do to CPU scheduling is going to be effective at accomplishing this task except in the most diaphanous, indirect way.