Linux preempt_rt 的缺点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10042550/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disadvantage(s) of preempt_rt
提问by Aquarius_Girl
the target hardware platform has limited horsepower, and/or you want the real-time job to put the smallest possible overhead on your system. This is where dual kernels are usually better than a native preemption system.
目标硬件平台的马力有限,和/或您希望实时作业对您的系统产生尽可能小的开销。这就是双内核通常比本地抢占系统更好的地方。
From here: http://www.xenomai.org/index.php/Xenomai:Roadmap#Xenomai_3_FAQ
从这里:http: //www.xenomai.org/index.php/Xenomai: Roadmap#Xenomai_3_FAQ
Preempt_rt does preempt the whole Linux. In what way does preempting Linux put load on the system?
Preempt_rt 确实抢占了整个 Linux。抢占 Linux 以何种方式给系统带来负载?
The FAQ there talks about the preempt_rt as compared to Xenomai.
与 Xenomai 相比,那里的 FAQ 讨论了 preempt_rt。
采纳答案by Aquarius_Girl
CONFIG_PREEMPT_VOLUNTARY-
This option introduces checks to the most common causes of long latencies in the kernel code, so that the kernel can voluntarily yield control to a higher priority task waiting to execute. This option is said to be reducing the occurrances of long latencies to a great degree but still it doesn't eliminate them totally.
CONFIG_PREEMPT_VOLUNTARY-
此选项引入了对内核代码中长时间延迟的最常见原因的检查,以便内核可以自愿将控制权交给等待执行的更高优先级任务。据说这个选项在很大程度上减少了长延迟的发生,但仍然没有完全消除它们。
CONFIG_PREEMPT_RT-
This option causes all kernel code outside of spinlock-protected regions (created by raw_spinlock_t), to be eligible for non-voluntary preemption by higher priority kernel threads. Spinlocks created by spinlock_t and rwlock_t, and the interrupts are also made preemptable with this option enabled. With this option, worst case latency drops to (around) single digit milliseconds.
CONFIG_PREEMPT_RT-
此选项导致自旋锁保护区域(由 raw_spinlock_t 创建)之外的所有内核代码有资格被更高优先级的内核线程非自愿抢占。由 spinlock_t 和 rwlock_t 创建的自旋锁和中断也可以在启用此选项的情况下抢占。使用此选项,最坏情况下的延迟会下降到(大约)个位数毫秒。
Disadvantage-
The normal Linux kernel allows preemption of a task by a higher priority task only when the user space code is getting executed.
缺点-
普通的 Linux 内核仅在执行用户空间代码时才允许更高优先级的任务抢占任务。
In order to reduce the latency, the CONFIG_PREEMPT_RT patch forces the kernel to non-voluntarily preempt the task at hand, at the arrival of a higher proiority kernel task. This is bound to cause a reduction in the overall throughput of the system since there will be several context switches and also the lower priority tasks won't be getting much a chance to get through.
为了减少延迟,CONFIG_PREEMPT_RT 补丁强制内核在更高优先级的内核任务到达时非自愿地抢占手头的任务。这必然会导致系统整体吞吐量的降低,因为会有几次上下文切换,并且较低优先级的任务也不会有太多机会通过。
Source: https://rt.wiki.kernel.org/index.php/Frequently_Asked_Questions
来源:https: //rt.wiki.kernel.org/index.php/Frequently_Asked_Questions
Description of technical terms used:
所用技术术语说明:
What is latency?
The time elasped between a demand issued on a computer system and the begining of a response to the same demand is called latency or response time.
Kinds of latencies:
什么是延迟?
在计算机系统上发出需求和开始响应同一需求之间经过的时间称为等待时间或响应时间。
延迟的种类:
- Interrupt Latency:
The time elapsed between the generation of an interrupt and the start of the execution of the corresponding interrupt handler.
Example: When a hardware device performs a task, it generates an interrupt. This interrupt has the information about the task to be performed and about the interrupt handler to be executed. The interrupt handler then performs the particular task. - Scheduling Latency:
It is the time between a wakeup signaling that an event has occurred and the kernel scheduler getting an opportunity to schedule the thread that is waiting for the wakeup to occur (the response). Scheduling latency is also known as dispatch latency. - Worst-case Latency:
The maximum amount of time that can laspe between a demand issued on a computer system and the begining of a response to the same demand.
- 中断延迟:
从产生中断到开始执行相应的中断处理程序之间经过的时间。
示例:当硬件设备执行任务时,它会产生中断。该中断包含有关要执行的任务和要执行的中断处理程序的信息。然后中断处理程序执行特定的任务。 - 调度延迟:
它是从发出事件发生的唤醒信号到内核调度程序有机会调度正在等待唤醒发生(响应)的线程之间的时间。调度延迟也称为调度延迟。 - 最坏情况延迟:
在计算机系统上发出的需求和对同一需求的响应开始之间可以持续的最长时间。
What is throughput?
Amount of work that a computer can do in a given period of time is called throughput.
什么是吞吐量?
计算机在给定时间内可以完成的工作量称为吞吐量。
What is Context switch?
Context switch is the switching of the CPU from one process/thread to another. Context switches can occur only in kernel mode. This is the process of saving the current execution state of the process (for resuming execution later on), and loading the saved state of the new process/thread for execution.
什么是上下文切换?
上下文切换是 CPU 从一个进程/线程切换到另一个进程/线程。上下文切换只能在内核模式下发生。这是保存进程当前执行状态(用于稍后恢复执行),并加载新进程/线程的保存状态以供执行的过程。
回答by Anon
Adding to top vote answer "lower priority tasks won't be getting much a chance to get through"
添加到最高投票答案“较低优先级的任务将没有太多机会通过”
That's sort of the whole point (though on a 4+ core system those low priority tasks could still run as long as they are forbidden from doing things that would interfere with critical tasks - this is where it's important to be able to make sure all the peripherals connected play nice by not blocking when the app running critical thread wants to access them). The critical bit (if for example thinking about developing a useful system for processing external input timely or testing behaviour of data conversion with live data as opposed to model), is to have a way to tell the kernel where the time critical input is arriving from.
这就是重点(尽管在 4+ 核心系统上,这些低优先级任务仍然可以运行,只要它们被禁止做会干扰关键任务的事情 - 这是重要的地方,能够确保所有当运行关键线程的应用程序想要访问它们时,连接的外围设备通过不阻塞而很好地发挥作用)。关键的一点(例如,如果考虑开发一个有用的系统来及时处理外部输入或使用实时数据而不是模型测试数据转换的行为),是有办法告诉内核时间关键输入来自哪里.
Problem with current eg. Windows systems is that you might be a "serious gamer or serious musician" that notices things like 150 microsecond jitters. If you have no way to specify that the keyboard, mouse or other human interface device should be treated at critical priority, then all sort of "windows updates" and such can come and do their thing which might in turn trigger some activity in the USB controller that has higher priority than the threads related to doing the input.
当前的问题,例如。在 Windows 系统中,您可能是“严肃的游戏玩家或严肃的音乐家”,会注意到诸如 150 微秒抖动之类的事情。如果您无法指定键盘、鼠标或其他人机接口设备应该被优先处理,那么所有类型的“Windows 更新”等都可以来做他们的事情,这可能反过来触发 USB 中的某些活动比与执行输入相关的线程具有更高优先级的控制器。
I read about a case where glitches in audio were resolved by adding a 2nd USB controller with nothing on it except the input device. In portable setting, you practically need Thunderbolt PCIe passthrough to add a dedicated hub (or fpga) that can, together with drivers, override everything else on the system. This is why the aren't much USB products on the market that provide good enough performance for musicians. (2 ms round trip latency with max 150 microsecond jitter over full day without dropouts)
我读到过一个案例,通过添加第二个 USB 控制器来解决音频中的故障,除了输入设备外,它没有任何东西。在便携式设置中,您实际上需要 Thunderbolt PCIe 直通来添加专用集线器(或 fpga),它可以与驱动程序一起覆盖系统上的所有其他内容。这就是为什么市场上为音乐家提供足够好的性能的USB产品并不多的原因。(2 ms 往返延迟,全天最大 150 微秒抖动,无丢失)