问题描述
我正在开发一个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?
谢谢!!
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 !!
这篇关于Windows XP和Windows 7中WaitForSingleObject的不同行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!