实时Windows - 它是如何完成的? C#/ C ++ [英] Real Time Windows - How is it done? C#/C++

查看:72
本文介绍了实时Windows - 它是如何完成的? C#/ C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一般来说,搜索有关如何获得实时或接近实时控制的信息通常会被视为无法使用Windows而被驳回。



但是多年来我一直在运行举几个与此观点相矛盾的例子:

GMFC泡沫切割软件 [ ^ ]



最近更新:

http://www.tenasys.com/tenasys-products/intime-rtos-family/intime-for-windows [ ^ ]



我相信来自我所看到的是用C#做类似的事情是不可能的,但我相信上面(至少GMFC)是用C / C ++编写的



在C#我有三个ed将线程优先级设置为我能够达到的最高值,并且从我的装备上进行测试,我最终得到200-300ms的延迟,我可以在一定程度上可靠地重现。



对于C ++看起来线程优先级太高,以至于它会开始干扰内部操作系统操作,并且可能无法执行硬盘读/写操作。



有没有Windows中编程任务的任何例子,需要子ms(甚至1ms)控制,同时仍然允许无错运行(根据需要分配一些时间片,以便操作系统可以完成必要的后台任务)?





例如,您如何使用类似于GMFC的并行端口在Windows中编写软件来控制步进电机?从我可以记住的,当它运行切割时,计算机将无法使用。 GMFC对话框将更新统计信息,但您将无法使用任何键盘或鼠标来执行任何操作。



不查找特定源代码示例(除非可用)在OSS或exmaples中)但更多的是策略将是什么(IE是否只是一个C ++应用程序,线程优先级最高设置手动释放时间片回到操作系统进行内务管理?)

Generally searching for information on how to obtain real time or near real time control generally is dismissed as not possible using Windows.

However over the years I have run into a few examples that contradict this viewpoint:
GMFC Foam Cutting Software[^]

And more recently:
http://www.tenasys.com/tenasys-products/intime-rtos-family/intime-for-windows[^]

I am sure from what I have read that doing something similar to the above is not possible with C# but I believe the above (at least GMFC) is written in C/C++

In C# I have tried to set the thread priority to the highest I can and from testing on my rig I end up with 200-300ms delays that I can somewhat reliably reproduce.

For C++ it looks like the thread priority can be so high that it will start to interfere with the internal OS operation and hard drive reads/writes may not be performed.

Is there any examples on programming tasks in windows that require sub ms (Or even 1ms) control while still allowing for error free operation (allocating some time slices as required so the OS can do its necessary background tasks)?


For example how would you write software in Windows to control a stepper motor using a parallel port in a similar fashion to GMFC? From what I can remember while it was running a cut the computer would be unusable. The GMFC dialog would update statistics but you would not be able to use any keyboard or mouse to do anyhthing.

Not looking for specific source code examples (unless this is available in OSS or exmaples) but more for what the strategy would be (IE is it just a C++ application with thread priority on highest setting manually releasing time slices back to the OS for housekeeping?)

推荐答案

一劳永逸:Windows不是一个实时操作系统。 ;-)



很容易忽视关于Windows上的计时器。一些新的 Windows 8.1上的计时器。 (即使对我来说)



一个很好的教程。我建议您坚持使用高分辨率计时器。
Once and for all: Windows isnt a real time operating system. ;-)

A good overlook about timers on Windows. Some new on Timers on Windows 8.1. (even for me)

A fine tutorial. I suggest you stick to High-Resolution Timer.


对于硬实时或接近硬实时控制,您可能必须编写设备驱动程序才能获得所需的响应。您的驱动程序将通过IOCTRL获取一系列命令以及您希望它们执行的次数。你可以在驱动程序中完成所有需要实时控制的操作,它可以在低于中断优先级的情况下运行,并且可以完全访问硬件。



所以如果你想要的话要知道怎么做,从微软获取Windows DDK(设备驱动开发套件)的副本,了解驱动程序的工作方式以及它们如何与Windows交互并获得编码!
For hard real-time or near hard real-time control you'll probably have to write a device driver to get the response you want. Your driver will take a sequence of commands and the times you want them executed for through IOCTRL. You'll do everything that needs real time control in the driver which can run at just below interrupt priority and give you full access to the hardware.

So if you want to know how to do it go and grab a copy of the Windows DDK (device drive development kit) from Microsoft, learn a bit about the way drivers work and how they interact with windows and get coding!


除了其他答案:



除了解决方案3的声明(关于没有硬实时):Windows甚至没有提供软实时。这根本不是实时的。我将通过以下方式表达它:对于每个固定的延迟值,有一些非零概率的响应变慢。无论这个概率对于长延迟值来说可能非常低,它仍然与实时要求相矛盾。请注意,还有许多其他技术与相同的属性与实时相矛盾:一个众所周知的元素是以太网。



多年前,我看到了一些信息在实时Windows版本或此类项目的规范,但目前我看不到它的痕迹。



我必须注意到,这里的争议很多源于不同在不同的知识领域中使用实时一词并不一致。例如,显示没有暂停的视频的能力通常也被称为实时,以及几乎可笑的互联网上的交互操作,例如与服务器推送或点对点的聊天。所有这些条款都不是基本的;我会建议避免它们以防止混淆。



-SA


这篇关于实时Windows - 它是如何完成的? C#/ C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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