实时编程使用Linux [英] Real-time programming with Linux

查看:303
本文介绍了实时编程使用Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚建立,并成立了香草Linux内核与应用RT补丁。一切都很好,我现在可以正确地引导进入新的内核。

I've just built and set up a vanilla Linux kernel with the RT patch applied. Everything went fine and I can now correctly boot into the new kernel.

什么让我怀疑是这样的:我有我用C做了一个模拟程序,我希望它在硬实时模式下执行,因为应该由新的内核被允许。也许整个模拟器并不需要与实时优先级运行,但一些任务里面做的。

What leaves me wondering is this: I have a simulator program that I've made in C, and I want it to execute in hard real time mode, as should be allowed by the new kernel. Probably the whole simulator doesn't need to be run with real-time priority, but some of the tasks inside do.

我怎样才能做到这一点?我认为,只需运行该程序不会做。

How can I accomplish this? I take it that simply running the program won't do.

推荐答案

如果你问如何运行的一些实时的背景下发生的线程,以及其他常规分时线程,那么你需要的是设置他们调度正确使用 sched_setscheduler

If you are asking how to run some of the threads in real-time context, and others as conventional time-sharing threads, then all you need is to set their schedulers properly using sched_setscheduler.

分时线要成为 SCHED_OTHER ;实时仿真线程希望 SCHED_FIFO SCHED_RR

Time-sharing threads want to be SCHED_OTHER; real-time simulator threads want to be SCHED_FIFO or SCHED_RR.

在Linux上,为了在实时优先级运行,用户必须拥有资源限制(男子2 RLIMIT ),允许这一点。特别是,你的 RTPRIO RLIMIT必须设置为你需要的最高优先级。另外,您也可以运行应用程序的根目录。在与PAM linux系统,这通常是通过增加适当的线来完成的 /etc/limits.conf

On Linux, in order to run at real-time priorities, your user must have resource limits (man 2 rlimit) that allows this. In particular, your rtprio rlimit must be set to the highest priority you will need. Alternatively, you can run the application as root. In a linux system with PAM, this is typically accomplished by adding the appropriate line to /etc/limits.conf

    @realtime   -  rtprio     99

这将授予RTPRIO最高限额实时优先级99到的实时的组。然后添加一个实时集团的/ etc /组,并确保你的用户是在一组。

This will grant rtprio limits up to real-time priority 99 to the realtime group. Then you add a real-time group to /etc/groups and make sure your user is in the group.

(而且因为这似乎是你第一次这样做,你可能也想身边有一个死人的开关高优先级实时线程,以确保您的模拟器不失控和导致系统崩溃......如果你是高仿真的CPU负载,你可能会得到实际的高CPU负荷,无法停止的事情而无需重新启动。)

(And since this appears to be your first time doing this, you may also want to have a "dead man's switch" high-priority real-time thread around to make sure that your simulator doesn't get out of hand and render the system unusable... if you are simulating high CPU load, you may get ACTUAL high CPU load and be unable to stop things without a reboot.)

这篇关于实时编程使用Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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