Windows XP和Windows 7中WaitForSingleObject的不同行为 [英] Different behavior for WaitForSingleObject in Windows XP and Windows 7

查看:234
本文介绍了Windows XP和Windows 7中WaitForSingleObject的不同行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个sofPLC程序,基本上,它通过以下步骤执行循环:


1)从I / O卡读取数据


2)执行我们的控制程序


3)将输出写入I / O卡


4)睡眠短时间


5)返回(1)


使用WaitForSingleObject实现步骤4(短暂睡眠)(阻止虚拟手柄并等待配置的超时,通常为5毫秒)。 MMC配置为最高精度(1毫秒)。此过程的优先级设置为
到REAL_TIME,线程优先级设置为最高。


在Windows XP中,实际的睡眠时间总是少于超过20毫秒,,但在Windows 7中这个时间是100毫秒!!



我知道Windows不是实时操作系统,但我不知道为什么在Windows 7这次与Windows如此不同XP。



我尝试过其他选项,如Sleep或SetWaitableTime,但我得到了相似的时间。甚至,我试图改变处理器亲和力,但我无法改善这些时间。


是否有任何方法可以知道哪个进程/线程阻塞了我的线程?


Windows 7是否更改了进程/线程调度程序(来自Windows XP?


谢谢!!



解决方案

您好,¥b $ b欢迎光临。


根据您的描述,我将把这个帖子移到一个更合适的论坛:Windows桌面SDK。


感谢您的理解。

问候,


I work developing a sofPLC program that, basically, it executes a loop with the following steps:

1) Reads data from an I/O card

2) Execute our control program

3) Write outputs to an I/O cards

4) Sleep for a short time

5) Back to (1)

Step 4 (Sleep for a short time) is implemented using WaitForSingleObject (blocking over a dummy handle and waiting for the configured timeout, that usually is 5 ms). The MMC is configured to the highest precision (1 ms). The priority of this process is set to REAL_TIME and the thread priority the hightest.

In Windows XP, the real sleep time is always less than 20 ms, but in Windows 7 this time is up 100 ms !!.

I know that Windows is not a realtime OS, but I don't know why in Windows 7 this time is so different from Windows XP.

I have tried other option such as Sleep or SetWaitableTime but I get similar times. Even, I tried to change the processor affinity but I can not improve these times.

Does exists any way to know which process/thread is blocking my thread?

Has Windows 7 changed the process/thread scheduler (from Windows XP?

Thanks !!

解决方案

Hello,
Welcome here.

Based on your description, I will move this thread to a more appropriate forum: Windows Desktop SDK.

Thanks for your understanding.
Regards,


这篇关于Windows XP和Windows 7中WaitForSingleObject的不同行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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