C ++ Code Real-Time选项 [英] C++ Code Real-Time option

查看:125
本文介绍了C ++ Code Real-Time选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All:



我想知道,我可以在我的C ++代码中设置我的exe实时吗?

所以:

而不是这样做:

1)运行exe

2)转到任务管理器 - >流程

3)设置优先级 - >实时



我将只运行我的exe,它将处理将优先级设置为实时?



太多问了吗?



Cheeers!

Hello All:

I was wondering, can I set my exe real time within my C++ code?
So:
Rather than doing this:
1) Run exe
2) Go to Task Manager -> Processes
3) Set Priority -> Real time

I will be just running my exe and it will deal with setting the priority to Real time?

Too much of an ask?

Cheeers!

推荐答案

永远不要设置优先权整个过程到实时。我可能会使您的系统冻结,而不是响应。我几乎所有情况下,你根本不应该触及优先事项。它无法帮助您,例如,提高某些任务的吞吐量。如果您真的知道自己在做什么,在非常非常罕见的情况下,您可以在提升的权限下运行代码的一些时间关键片段(通常非常短暂):

http://msdn.microsoft.com/en-us/library/ windows / desktop / ms686219%28v = vs.85%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686277%28v=vs.85% 29.aspx [ ^ ]。



您应该始终设置更高的优先级并在try-finally块下恢复原始优先级,以保证恢复先前设定的pri orities。



-SA
Never set the priority of a whole process to real time. I may render your system frozen, not responsive. I almost all cases, you simply should not touch priorities. It cannot help you, for example, improve the throughput of some task. If you really know what you are doing, in really, really rare cases, you can run some time-critical fragment (usually very short in time) of your code under elevated privileges:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686219%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686277%28v=vs.85%29.aspx[^].

You should always set higher priorities and restore original priorities under try-finally block, to guarantee restoring of the previously set priorities.

—SA


我建​​议你先考虑一下你真正需要的东西:



- '硬实时'只能通过实时操作系统来实现 [ ^ ],但它会保证控制流将始终在特定的硬时限内传递给您的应用程序(取决于CPU和操作系统)



- '软实时'在技术上可以是用任何操作系统实现。它只能保证您的应用程序能够在大多数时间的时间限制内作出反应。时间限制和可能实现的可能性在很大程度上取决于操作系统,显然,实时操作系统可以实现更好的数字。



- '高优先级'平均而言,让你的程序尽可能快地运行。根本不需要保证最多需要多长时间,或信号到达您的应用程序需要多长时间。没有任何证据或迹象表明Windows所谓的实时与此有任何不同。



如果高优先级不足以达到您的目的,那么我强烈建议找一个实时操作系统。您可以开始查看此处 [ ^ ]
I suggest you first consider what you actually need:

- 'hard realtime' can only be achieved with a real time OS[^], but it will guarantee that the flow of control will always be passed to your application within a specific hard time limit (depending on the CPU and the OS)

- 'soft realtime' can technically be achieved with any OS. It will only guarantee that your application will be able to react within a time limit most of the time. The time limit and the likelyhood it can be achieved strongly depends on the OS, and, obviously, a Realtime OS can achieve much better numbers.

- 'high priority' will let your program run as fast as reasonably possible, on average. There is no guarantee at all at how long it will take at most, or how long it will take for a signal to reach your application. There is no proof or indication that what Windows calls 'Real Time' is really any different from this.

If 'high priority' is not enough for your purposes, then I strongly suggest to find a real time OS. You can start looking here[^]


这篇关于C ++ Code Real-Time选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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